-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmain.py
39 lines (26 loc) · 1.04 KB
/
main.py
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
import signal
import sys
import traceback
from PyQt6.QtWidgets import QApplication
from ducktrack import MainInterface
def main():
app = QApplication(sys.argv)
app.setQuitOnLastWindowClosed(False)
signal.signal(signal.SIGINT, signal.SIG_DFL)
interface = MainInterface(app)
interface.show()
# TODO: come up with a better error solution to this
original_excepthook = sys.excepthook
def handle_exception(exc_type, exc_value, exc_traceback):
print("Exception type:", exc_type)
print("Exception value:", exc_value)
trace_details = traceback.format_exception(exc_type, exc_value, exc_traceback)
trace_string = "".join(trace_details)
print("Exception traceback:", trace_string)
message = f"An error occurred!\n\n{exc_value}\n\n{trace_string}"
interface.display_error_message(message)
original_excepthook(exc_type, exc_value, exc_traceback)
sys.excepthook = handle_exception
sys.exit(app.exec())
if __name__ == "__main__":
main()