diff options
author | emkael <emkael@tlen.pl> | 2019-06-27 13:02:38 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-06-27 13:02:38 +0200 |
commit | 06dbe4b0a0021ab6e96324dfd729f7b4b9c60101 (patch) | |
tree | 080ca935a7666c1644711906f8ddbba1a782f94d /jfr_playoff/gui/frames/visual.py | |
parent | 9d0176306e53934d3f6d1a2082ee82711d16d725 (diff) |
Reusable setValue for WidgetRepeater
Diffstat (limited to 'jfr_playoff/gui/frames/visual.py')
-rw-r--r-- | jfr_playoff/gui/frames/visual.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/jfr_playoff/gui/frames/visual.py b/jfr_playoff/gui/frames/visual.py index 0e2828b..ecc6e03 100644 --- a/jfr_playoff/gui/frames/visual.py +++ b/jfr_playoff/gui/frames/visual.py @@ -248,17 +248,15 @@ class BoxPositionsFrame(ScrollableFrame): def setValues(self, values): values = sorted(list(values.iteritems()), key=lambda v: int(v[0])) + values_to_set = [] for idx, val in enumerate(values): value = [val[0]] if isinstance(val[1], list): value += val[1] else: value.append(val[1]) - if idx >= len(self.positions.widgets): - self.positions._addWidget() - self.positions.widgets[idx].setValue(value) - for idx in range(len(values), len(self.positions.widgets)): - self.positions._removeWidget(idx) + values_to_set.append(value) + self.positions.setValue(values_to_set) class LineStyle(GuiFrame): def _selectColour(self): @@ -396,11 +394,6 @@ class PositionStylesFrame(ScrollableFrame): self.styles.pack(side=tk.TOP, fill=tk.BOTH, expand=True) def setValues(self, values): - for idx, value in enumerate(values): - if idx >= len(self.styles.widgets): - self.styles._addWidget() - self.styles.widgets[idx].setValue(value) - for idx in range(len(values), len(self.styles.widgets)): - self.styles._removeWidget(idx) + self.styles.setValue(values) __all__ = ['VisualSettingsFrame', 'BoxPositionsFrame', 'LineStylesFrame', 'PositionStylesFrame'] |