From b4bf2e464dc3f01f2ced9189f0ba22748574bfe1 Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 30 Jul 2019 12:32:37 +0200 Subject: Error handling in the parent, GUI thread --- jfr_playoff/gui/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'jfr_playoff/gui') diff --git a/jfr_playoff/gui/__init__.py b/jfr_playoff/gui/__init__.py index 56ed1cb..2bd0981 100644 --- a/jfr_playoff/gui/__init__.py +++ b/jfr_playoff/gui/__init__.py @@ -38,6 +38,7 @@ class PlayoffGUI(tk.Tk): self._dirty.trace('w', self._setTitle) self._dirty.trace('w', self._setMenuButtons) self._runTimer = None + self._runtimeError = None self._filepath = None self.protocol('WM_DELETE_WINDOW', self.onClose) @@ -53,6 +54,7 @@ class PlayoffGUI(tk.Tk): self.newFile() self.bind('<>', self._onFileChange, add='+') self.bind('<>', self._onBracketGenerated, add='+') + self.bind('<>', self._onBracketError, add='+') self.mainloop() def _onFileChange(self, *args): @@ -189,7 +191,8 @@ class PlayoffGUI(tk.Tk): except Exception as e: log.getLogger().error(str(e)) if interactive: - tkmb.showerror('Błąd generowania drabinki', str(e)) + self._runtimeError = e + self.event_generate('<>', when='tail') def _onBracketGenerated(self, *args): self._setRunWidgetState(tk.NORMAL) @@ -199,6 +202,11 @@ class PlayoffGUI(tk.Tk): 'Otworzyć drabinkę w domyślnej przeglądarce?'): webbrowser.open(self._outputPath) + def _onBracketError(self, *args): + tkmb.showerror('Błąd generowania drabinki', str(self._runtimeError)) + self._setRunWidgetState(tk.NORMAL) + self._runtimeError = None + def _setRunWidgetState(self, state): self.menuButtons['run-once'].configure(state=state) self.runningLabel.configure( -- cgit v1.2.3