diff options
author | emkael <emkael@tlen.pl> | 2019-11-16 20:33:30 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-11-16 20:33:30 +0100 |
commit | eac17e5b695bab56cdd9774f302d8e5fe9889576 (patch) | |
tree | 8189d95ce2562c66c59446577e9a5a85e257471a | |
parent | 738ea152da21bc15b711949a116e16a2183894b6 (diff) |
Scrolling phase pane on new match add
-rw-r--r-- | jfr_playoff/gui/frames/__init__.py | 6 | ||||
-rw-r--r-- | jfr_playoff/gui/frames/match.py | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py index f4fdf4f..052e832 100644 --- a/jfr_playoff/gui/frames/__init__.py +++ b/jfr_playoff/gui/frames/__init__.py @@ -19,7 +19,7 @@ def setPanelState(frame, state): class WidgetRepeater(tk.Frame): def __init__(self, master, widgetClass, headers=None, classParams=None, - *args, **kwargs): + onAdd=None, *args, **kwargs): widgetList = widgetClass if not isinstance(widgetClass, list): widgetList = [widgetClass] @@ -35,6 +35,7 @@ class WidgetRepeater(tk.Frame): self.headerFrame = None self.addButton = ttk.Button( self, text='[+]', width=5, command=self._addWidget) + self.onAdd = onAdd self.renderContent() def _findWidget(self, row, column): @@ -56,6 +57,8 @@ class WidgetRepeater(tk.Frame): widget.configureContent(**widgetClassParams) self.widgets.append(widget) self._updateGrid() + if self.onAdd is not None: + self.onAdd(widget) def _handleWidgetSelection(self, selected): if selected < len(self.widgetClass): @@ -245,6 +248,7 @@ class ScrollableFrame(tk.Frame): def renderContent(self, container): pass + class WidgetSelectionFrame(ScrollableFrame): def __init__(self, *args, **kwargs): self.widgets = [] diff --git a/jfr_playoff/gui/frames/match.py b/jfr_playoff/gui/frames/match.py index e7f86fc..2cf88bf 100644 --- a/jfr_playoff/gui/frames/match.py +++ b/jfr_playoff/gui/frames/match.py @@ -807,12 +807,16 @@ class MatchPhaseFrame(ScrollableFrame): side=tk.LEFT, fill=tk.X, expand=True) self.matches = WidgetRepeater( - container, [MatchSettingsFrame, MatchSeparator]) + container, [MatchSettingsFrame, MatchSeparator], + onAdd=self._matchAdded) self.matches.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.link.trace('w', self._updateLinks) self.name.trace('w', self._signalPhaseRename) + def _matchAdded(self, widget): + self.after(100, self.canvas.yview_moveto, 1.0) + def setValues(self, values): matches = values['matches'] if 'matches' in values else [] dummies = values['dummies'] if 'dummies' in values else [] |