Skip to content

Commit 55481aa

Browse files
committed
Improve button layout of ScanFig interfaces
1 parent 0db027a commit 55481aa

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

psctb/utils/plotting/_plotting.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,18 +765,23 @@ def _widgets(self):
765765
if not self._widgets_:
766766
widget_classes = OrderedDict()
767767
for k in self._category_classes.iterkeys():
768-
widget_classes[k] = widgets.HBox()
769-
768+
box = widgets.HBox()
769+
box.layout.display = 'flex-flow'
770+
widget_classes[k] = box
770771
def oc(cat):
771772
def on_change(name, value):
772773
self.toggle_category(cat, value)
773774
self.show()
774775

775776
return on_change
776777

778+
779+
width = self._find_button_width()
780+
777781
for each in self._categories:
778782
w = widgets.ToggleButton()
779783
w.description = each
784+
w.width = width
780785
w.value = self.categories_status[each]
781786
on_change = oc(each)
782787
w.on_trait_change(on_change, 'value')
@@ -1113,3 +1118,12 @@ def adjust_figure(self):
11131118
display(self._save_button)
11141119
# self._save_button.remove_class('vbox')
11151120
# self._save_button.add_class('hbox')
1121+
1122+
def _find_button_width(self):
1123+
longest = sorted([len(each) for each in self._categories])[-1]
1124+
if longest > 14:
1125+
width_px = (longest - 14) * 5 + 145
1126+
width = str(width_px) + 'px'
1127+
else:
1128+
width = '145px'
1129+
return width

0 commit comments

Comments
 (0)