diff options
author | emkael <emkael@tlen.pl> | 2019-12-27 20:58:02 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-12-27 20:58:02 +0100 |
commit | c0f4f1210b9686fb9e79935673ca1b8a4e9bf7c8 (patch) | |
tree | c3ee823e2a018f45472d7804e4e6b3731c750dfd /jfr_playoff/gui/frames | |
parent | c9090b822d731c52594b48a80550588e277d394a (diff) |
Proper change notifications for widget repeater and selection button/frame
Fixes #41
Diffstat (limited to 'jfr_playoff/gui/frames')
-rw-r--r-- | jfr_playoff/gui/frames/__init__.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py index 052e832..cca19a5 100644 --- a/jfr_playoff/gui/frames/__init__.py +++ b/jfr_playoff/gui/frames/__init__.py @@ -7,8 +7,8 @@ import tkinter as tk from tkinter import ttk import tkMessageBox -from ..variables import NotifyStringVar, NotifyIntVar -from ..variables import NotifyBoolVar, NotifyNumericVar, NumericVar +from ..variables import BoolVar +from ..variables import NotifyStringVar, NotifyNumericVar, NumericVar def setPanelState(frame, state): for child in frame.winfo_children(): @@ -100,6 +100,7 @@ class WidgetRepeater(tk.Frame): self.addButton.grid( row=len(self.widgets)+headeridx, column=0, columnspan=1, sticky=tk.W+tk.N) + self.event_generate('<<ValueChanged>>', when='tail') def _renderHeader(self): if self.headers: @@ -263,7 +264,7 @@ class WidgetSelectionFrame(ScrollableFrame): addBtn.pack(side=tk.BOTTOM) def renderContent(self, container): - self.value = NotifyIntVar() + self.value = tk.IntVar() for idx, widget in enumerate(self.widgets): (ttk.Radiobutton( container, variable=self.value, value=idx, @@ -298,6 +299,7 @@ class SelectionButton(ttk.Button): kwargs['command'] = self._choosePositions if self.prompt is None: self.prompt = self.defaultPrompt + self._trackChanges = False ttk.Button.__init__(self, *args, **kwargs) self.setPositions([]) @@ -307,6 +309,8 @@ class SelectionButton(ttk.Button): text='[wybrano: %d]' % (len(values))) if self.callback is not None: self.callback(values) + if self._trackChanges: + self.event_generate('<<ValueChanged>>', when='tail') def _choosePositions(self): options = self.getOptions() @@ -319,6 +323,7 @@ class SelectionButton(ttk.Button): dialog.title(self.title) dialog.grab_set() dialog.focus_force() + self._trackChanges = True selectionFrame = self.dialogclass( dialog, title=self.prompt, options=options, @@ -360,7 +365,7 @@ class SelectionFrame(ScrollableFrame): self.renderHeader(container) for idx, option in enumerate(self.options): key = self._mapValue(idx, option) - self.values[key] = NotifyBoolVar() + self.values[key] = BoolVar() self.renderOption(container, option, idx) if self.selected and key in self.selected: self.values[key].set(True) |