Skip to content

Commit a656d11

Browse files
committed
fix GUI errors
1 parent ddc69d5 commit a656d11

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

VW_Flash_GUI.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,29 @@
4747
# Get an instance of logger, which we'll pull from the config file
4848
logger = logging.getLogger("VWFlash")
4949

50+
5051
def handle_exception(exc_type, exc_value, exc_traceback):
5152
if issubclass(exc_type, KeyboardInterrupt):
5253
sys.__excepthook__(exc_type, exc_value, exc_traceback)
5354
return
54-
5555
logger.error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback))
56+
dlg = wx.MessageDialog(
57+
None,
58+
f"A Python exception occured: {exc_type}, {exc_value}. Please check the log file.",
59+
"Error!",
60+
wx.OK | wx.ICON_ERROR | wx.CENTRE,
61+
)
62+
dlg.ShowModal()
63+
dlg.Destroy()
64+
65+
66+
def handle_threaded_exception(args, /):
67+
(exc_type, exc_value, exc_traceback, thread) = args
68+
handle_exception(exc_type, exc_value, exc_traceback)
5669

57-
try:
58-
wx.MessageDialog(
59-
None,
60-
f"A Python exception occured: {exc_type}, {exc_value}. Please check the log file.",
61-
wx.OK | wx.ICON_ERROR | wx.CENTRE,
62-
).ShowModal()
63-
finally:
64-
return
6570

6671
sys.excepthook = handle_exception
72+
threading.excepthook = handle_threaded_exception
6773

6874
try:
6975
currentPath = path.dirname(path.abspath(__file__))

0 commit comments

Comments
 (0)