forked from FABallemand/ProjetAlgorithmesDuTexte
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
41 lines (34 loc) · 1.09 KB
/
Copy pathmain.py
File metadata and controls
41 lines (34 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sys, signal
from PyQt5.QtWidgets import QApplication
from qt_material import apply_stylesheet
from src import *
def main():
"""
Main function.
"""
def signalHandler(*args):
"""
Handler for the SIGINT signal.
"""
sys.stderr.write("\r")
if QMessageBox.question(None,
"",
"Are you sure you want to quit?",
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No) == QMessageBox.Yes:
window.signalHandler()
_app.quit()
# Create application
_app = QApplication(sys.argv)
window = Application()
apply_stylesheet(_app, theme="dark_red.xml")
# Signal handler
signal.signal(signal.SIGINT, signalHandler)
# Allow Python interpreter to run every few seconds to handle signals
timer = QTimer()
timer.start(500)
timer.timeout.connect(lambda: None) # Let the interpreter run each 500 ms.
# Run application
sys.exit(_app.exec_())
if __name__ == "__main__":
main()