def update(self): """ Sets up the button widget """ if self._widget != None: self.removeChild(self._widget) self._widget = None if self._action is None: return widget = None icon = None text = None if self._action.isSeparator(): widget = widgets.VBox() widget.base_color += Color(8, 8, 8) widget.min_size = (2, 2) else: if self._button_style != ToolBar.BUTTON_STYLE['TextOnly'] and len(self._action.icon) > 0: if self._action.isCheckable(): icon = widgets.ToggleButton(hexpand=0, up_image=self._action.icon,down_image=self._action.icon,hover_image=self._action.icon,offset=(1,1)) icon.toggled = self._action.isChecked() else: icon = widgets.ImageButton(hexpand=0, up_image=self._action.icon,down_image=self._action.icon,hover_image=self._action.icon,offset=(1,1)) icon.capture(self._action.activate) if self._button_style != ToolBar.BUTTON_STYLE['IconOnly'] or len(self._action.icon) <= 0: if self._action.isCheckable(): text = widgets.ToggleButton(hexpand=0, text=self._action.text,offset=(1,1)) text.toggled = self._action.isChecked() else: text = widgets.Button(text=self._action.text) text.capture(self._action.activate) if self._button_style == ToolBar.BUTTON_STYLE['TextOnly'] or len(self._action.icon) <= 0: widget = text elif self._button_style == ToolBar.BUTTON_STYLE['TextUnderIcon']: widget = widgets.VBox() icon.position_technique = "center:top" text.position_technique = "center:bottom" widget.addChild(icon) widget.addChild(text) elif self._button_style == ToolBar.BUTTON_STYLE['TextBesideIcon']: widget = widgets.HBox() widget.addChild(icon) widget.addChild(text) else: widget = icon widget.position_technique = "left:center" widget.hexpand = 0 self._widget = widget self.addChild(self._widget)
def buildGui(self): if self.gui: self.removeChild(self.gui) if self.side == "left" or self.side == "right": self.gui = widgets.VBox() else: self.gui = widgets.HBox() self.gui.vexpand = 1 self.gui.hexpand = 1 self.addChild(self.gui)
def _updateToolbar(self): actions = self._actions self.clear() if self._orientation == ToolBar.ORIENTATION['Vertical']: self.gui = widgets.VBox(min_size=(self._panel_size, self._panel_size)) else: self.gui = widgets.HBox(min_size=(self._panel_size, self._panel_size)) self.addChild(self.gui) for action in actions: self.addAction(action) self.adaptLayout()
def __init__(self,callback,**kwargs): super(ObjectIcon,self).__init__(**kwargs) self.callback = callback self.capture(self._mouseEntered, "mouseEntered") self.capture(self._mouseExited, "mouseExited") self.capture(self._mouseClicked, "mouseClicked") vbox = widgets.VBox(padding=3) # Icon self.icon = widgets.Icon(**kwargs) self.addChild(self.icon) # Label hbox = widgets.HBox(padding=1) self.addChild(hbox) self.label = widgets.Label(**kwargs) hbox.addChild(self.label)
def __init__(self, resizable=None, *args, **kwargs): if resizable == None: resizable = False widgets.VBox.__init__(self, *args, **kwargs) ResizableBase.__init__(self, resizable, *args, **kwargs) self.tabs = [] self.buttonbox = widgets.HBox() self.widgetarea = widgets.VBox() self.buttonbox.hexpand = 1 self.buttonbox.vexpand = 0 self.widgetarea.hexpand = 1 self.widgetarea.vexpand = 1 self.addChild(self.buttonbox) self.addChild(self.widgetarea) self.resizable_top = False self.resizable_left = False self.resizable_right = False self.resizable_bottom = False