Example #1
0
 def _add_toolbar_group(self, group, func, default_value):
     button_group = QButtonGroup(parent=self.toolbar)
     for element in group:
         icon = self.icons.get(element, None)
         button = QToolButton()
         button.setFixedSize(QSize(*self.icon_size))
         button.setIcon(icon)
         button.setCheckable(True)
         if default_value is not None and element is default_value:
             button.setChecked(True)
         button.toggled.connect(DefaultFunction(func, element))
         button_group.addButton(button)
         self.toolbar.addWidget(button)
Example #2
0
 def _add_toolbar_toggles(self):
     for toggle in Toggle:
         icon = self.icons.get(toggle, None)
         button = QToolButton()
         button.setFixedSize(QSize(*self.icon_size))
         button.setIcon(icon)
         button.setCheckable(True)
         toggle_name = toggle.name.lower()
         default_value = self.params["builder"]["toggles"][toggle_name]
         func_name = "toggle_{}".format(toggle_name)
         func = getattr(self, func_name, None)
         assert callable(func)
         button.toggled.connect(func)
         button.setChecked(default_value)
         func(default_value)
         self.toolbar.addWidget(button)