From d75941019eab5414b2b01d6689ce1a03b69499e6 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 19 Jul 2019 12:08:58 +0200 Subject: Refactoring menu code --- jfr_playoff/gui/__init__.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/jfr_playoff/gui/__init__.py b/jfr_playoff/gui/__init__.py index e6e512f..b59b044 100644 --- a/jfr_playoff/gui/__init__.py +++ b/jfr_playoff/gui/__init__.py @@ -65,22 +65,13 @@ class PlayoffGUI(tk.Tk): def _buildMenu(self): menu = tk.Frame(self) menu.pack(side=tk.TOP, fill=tk.X) - (ttk.Button( - menu, - image=GuiImage.get_icon('new'), command=self.onNewFile)).pack( - side=tk.LEFT) - (ttk.Button( - menu, - image=GuiImage.get_icon('open'), command=self.onFileOpen)).pack( - side=tk.LEFT) - (ttk.Button( - menu, - image=GuiImage.get_icon('save'), command=self.onSave)).pack( - side=tk.LEFT) - (ttk.Button( - menu, - image=GuiImage.get_icon('saveas'), command=self.onSaveAs)).pack( - side=tk.LEFT) + for icon, command in [('new', self.onNewFile), + ('open', self.onFileOpen), + ('save', self.onSave), + ('saveas', self.onSaveAs)]: + (ttk.Button( + menu, image=GuiImage.get_icon(icon), command=command)).pack( + side=tk.LEFT) def onNewFile(self): self._checkSave() -- cgit v1.2.3