-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec3635b
commit a2a6b04
Showing
3 changed files
with
33 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,3 +90,5 @@ ENV/ | |
|
||
# pytest | ||
.pytest_cache/ | ||
|
||
screenshot-light.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,43 @@ | ||
import sys | ||
|
||
from PyQt5.QtCore import QTimer | ||
from PyQt5.QtWidgets import QApplication | ||
from PyQt5.QtGui import QGuiApplication | ||
from PyQt5.QtWidgets import QApplication, QMainWindow | ||
|
||
from torf_gui.gui import TorfGUI | ||
from torf_gui import __version__ | ||
from torf_gui.ui_mainwindow import Ui_MainWindow | ||
|
||
PROGRAM_NAME = "torf-gui" | ||
PROGRAM_NAME_VERSION = f"{PROGRAM_NAME} {__version__}" | ||
|
||
# Create an instance of the application | ||
app = QApplication(sys.argv) | ||
|
||
# Create an instance of the main window class, set up its UI, and show it | ||
main_window = TorfGUI() | ||
main_window.setupUi(main_window) | ||
main_window.show() | ||
# Create a QMainWindow and set up the Ui_MainWindow in it | ||
main_window = QMainWindow() | ||
ui = Ui_MainWindow() | ||
ui.setupUi(main_window) | ||
# Set the window title | ||
main_window.setWindowTitle(PROGRAM_NAME_VERSION) | ||
|
||
|
||
# Function to take screenshot | ||
def take_screenshot(): | ||
# Grab the screen that contains the window | ||
screen = QGuiApplication.screenAt(main_window.geometry().center()) | ||
if screen is not None: | ||
# Grab the entire screen and crop it to the window geometry | ||
screenshot = screen.grabWindow(QApplication.desktop().winId()) | ||
cropped_screenshot = screenshot.copy(main_window.frameGeometry()) | ||
# Save the cropped screenshot to a file | ||
cropped_screenshot.save("screenshot-light.png", "png") | ||
# Quit the application | ||
QApplication.quit() | ||
|
||
|
||
# Set a timer to take the screenshot after 5 seconds | ||
QTimer.singleShot(5000, main_window.take_screenshot) | ||
QTimer.singleShot(5000, take_screenshot) | ||
|
||
# Start the application | ||
main_window.show() | ||
sys.exit(app.exec_()) |