From 5cdfee5a5e402a0213ae0bca3aa9290a0263402c Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 21 Jun 2019 21:22:05 +0200 Subject: Renaming phase tab labels dynamically --- jfr_playoff/gui/frames/match.py | 4 ++++ jfr_playoff/gui/tabs.py | 9 +++++++++ 2 files changed, 13 insertions(+) (limited to 'jfr_playoff/gui') diff --git a/jfr_playoff/gui/frames/match.py b/jfr_playoff/gui/frames/match.py index b785f99..6772e6b 100644 --- a/jfr_playoff/gui/frames/match.py +++ b/jfr_playoff/gui/frames/match.py @@ -387,6 +387,9 @@ class MatchPhaseFrame(ScrollableFrame): match.link.set(self.link.get()) self.previousLink = self.link.get() + def _signalPhaseRename(self, *args): + self.winfo_toplevel().event_generate('<>', when='tail') + def renderContent(self, container): self.previousLink = '' headerFrame = tk.Frame(container) @@ -403,6 +406,7 @@ class MatchPhaseFrame(ScrollableFrame): self.matches.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.link.trace('w', self._updateLinks) + self.name.trace('w', self._signalPhaseRename) __all__ = ['SwissesFrame', 'MatchPhaseFrame', 'MatchSettingsFrame'] diff --git a/jfr_playoff/gui/tabs.py b/jfr_playoff/gui/tabs.py index ed06237..9d41f91 100644 --- a/jfr_playoff/gui/tabs.py +++ b/jfr_playoff/gui/tabs.py @@ -185,6 +185,12 @@ class MatchesTab(PlayoffTab): if key_to_delete: self.phases.pop(key_to_delete) + def _renameTabs(self, *args): + for idx, tab in self.phases.iteritems(): + title = tab.name.get().strip() + self.phaseFrame.tab( + tab, text=title if len(title) else 'Faza #%d' % (idx)) + def renderContent(self, container): container.columnconfigure(1, weight=1) container.rowconfigure(2, weight=1) @@ -201,6 +207,9 @@ class MatchesTab(PlayoffTab): self.phaseFrame.grid( row=2, column=0, columnspan=2, sticky=tk.W+tk.E+tk.N+tk.S) + self.winfo_toplevel().bind( + '<>', self._renameTabs, add='+') + def getMatches(self): matches = [] for phase in self.phases.values(): -- cgit v1.2.3