diff options
author | emkael <emkael@tlen.pl> | 2019-11-16 20:54:47 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-11-16 20:54:47 +0100 |
commit | bf96dd0cfa0da5080c33852a2a2af55b12030825 (patch) | |
tree | e80c736520618dae2d22051a788e01164ee2cffd /jfr_playoff | |
parent | eac17e5b695bab56cdd9774f302d8e5fe9889576 (diff) |
Keyboard shortcuts: fixes #36
Diffstat (limited to 'jfr_playoff')
-rw-r--r-- | jfr_playoff/gui/__init__.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/jfr_playoff/gui/__init__.py b/jfr_playoff/gui/__init__.py index fca456b..5d9e40f 100644 --- a/jfr_playoff/gui/__init__.py +++ b/jfr_playoff/gui/__init__.py @@ -40,6 +40,7 @@ class PlayoffGUI(tk.Tk): self._runTimer = None self._runtimeError = None self._filepath = None + self._bindKeyboardShortcuts() self.protocol('WM_DELETE_WINDOW', self.onClose) def run(self): @@ -134,11 +135,19 @@ class PlayoffGUI(tk.Tk): tooltip=tooltip, label=statusBar) self.menuButtons[icon].pack(side=tk.LEFT) - def onNewFile(self): + def _bindKeyboardShortcuts(self): + self.bind('<Control-n>', self.onNewFile) + self.bind('<Control-s>', self.onSave) + self.bind('<Control-S>', self.onSaveAs) + self.bind('<Control-o>', self.onFileOpen) + self.bind('<Control-q>', self.onClose) + self.bind('<F9>', self.onRunOnce) + + def onNewFile(self, *args): self._checkSave() self.newFile() - def onFileOpen(self): + def onFileOpen(self, *args): self._checkSave() filename = tkfd.askopenfilename( title='Wybierz plik drabniki', @@ -147,13 +156,13 @@ class PlayoffGUI(tk.Tk): if filename: self.openFile(filename) - def onSave(self): + def onSave(self, *args): if self._filepath is not None: self.saveFile(self._filepath) else: self.onSaveAs() - def onSaveAs(self): + def onSaveAs(self, *args): filename = tkfd.asksaveasfilename( title='Wybierz plik drabniki', filetypes=(('JFR Teamy Play-Off files', '*.jtpo'), |