diff options
author | emkael <emkael@tlen.pl> | 2019-07-30 12:32:37 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-07-30 12:32:37 +0200 |
commit | b4bf2e464dc3f01f2ced9189f0ba22748574bfe1 (patch) | |
tree | b122d321b6b32052693955cb0539fe3028c377ed | |
parent | b67eef0f06be286de6ef3732e8f85801bf440dd0 (diff) |
Error handling in the parent, GUI thread
-rw-r--r-- | jfr_playoff/gui/__init__.py | 10 |
1 files changed, 9 insertions, 1 deletions
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('<<ValueChanged>>', self._onFileChange, add='+') self.bind('<<BracketGenerated>>', self._onBracketGenerated, add='+') + self.bind('<<BracketError>>', 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('<<BracketError>>', 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( |