summaryrefslogtreecommitdiff
path: root/jfr_playoff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-07-21 15:01:59 +0200
committeremkael <emkael@tlen.pl>2019-07-21 15:01:59 +0200
commit10dfe8a4123d1dbdb0b2534ab4b0054e085b8a6e (patch)
tree409998b32e71748a3b16a1e9074913be7365c270 /jfr_playoff
parentd75941019eab5414b2b01d6689ce1a03b69499e6 (diff)
Activate "save" button depending on dirty state
Diffstat (limited to 'jfr_playoff')
-rw-r--r--jfr_playoff/gui/__init__.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/jfr_playoff/gui/__init__.py b/jfr_playoff/gui/__init__.py
index b59b044..59821cb 100644
--- a/jfr_playoff/gui/__init__.py
+++ b/jfr_playoff/gui/__init__.py
@@ -17,13 +17,14 @@ class PlayoffGUI(tk.Tk):
ttk.Style().configure('TLabelframe', padding=5)
self.geometry('920x640')
self.tabs = {}
+ self._buildMenu()
self.newFileIndex = 0
self._title = tk.StringVar()
self._title.trace('w', self._setTitle)
self._dirty = tk.BooleanVar()
self._dirty.trace('w', self._setTitle)
+ self._dirty.trace('w', self._setMenuButtons)
self._filepath = None
- self._buildMenu()
def run(self):
self.notebook = ttk.Notebook(self)
@@ -55,6 +56,10 @@ class PlayoffGUI(tk.Tk):
' *' if self._dirty.get() else ''
))
+ def _setMenuButtons(self, *args):
+ self.menuButtons['save'].configure(
+ state=tk.NORMAL if self._dirty.get() else tk.DISABLED)
+
def _setValues(self, config):
for tab in self.tabs.values():
tab.setValues(config)
@@ -65,13 +70,14 @@ class PlayoffGUI(tk.Tk):
def _buildMenu(self):
menu = tk.Frame(self)
menu.pack(side=tk.TOP, fill=tk.X)
+ self.menuButtons = {}
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)
+ self.menuButtons[icon] = ttk.Button(
+ menu, image=GuiImage.get_icon(icon), command=command)
+ self.menuButtons[icon].pack(side=tk.LEFT)
def onNewFile(self):
self._checkSave()