def add_button(self, **kwargs): import sys # intercept/adjust some of the arguments for (key, val) in kwargs.iteritems(): # get full image path if key.startswith("image") and IconFactory.is_icon_path(val): kwargs[key] = self.icon_factory.disk_path(val) cmds.setParent("|".join([self.layout, self.name])) cmds.shelfButton(**kwargs)
def add_button(self, **kwargs): # so not sure if this is going to work, yay programming! # intercept/adjust some of the arguments cmd = kwargs.get('command', 'print "No action defined"') label = kwargs.get('label', 'Unknown') annotation = kwargs.get('annotation', '') image = QtGui.QPixmap() for (key, val) in kwargs.iteritems(): if key.startswith("image") and IconFactory.is_icon_path(val): image = QtGui.QIcon(self.icon_factory.disk_path(val)) action = QtGui.QAction(self.widget) action.setIcon(image) action.setToolTip(annotation) action.triggered.connect(lambda: self._exec_cmd(cmd)) button = QtGui.QToolButton() button.setAutoRaise(True) button.setDefaultAction(action) self.layout.addWidget(button)
def add_button(self, **kwargs): # so not sure if this is going to work, yay programming! # intercept/adjust some of the arguments cmd = kwargs.get('command', 'print "No action defined"') label = kwargs.get('label', 'Unknown') annotation = kwargs.get('annotation', '') image = QtGui.QPixmap() for (key, val) in kwargs.iteritems(): if key.startswith("image") and IconFactory.is_icon_path(val): image = QtGui.QIcon(self.icon_factory.disk_path(val)) action = QtGui.QAction(self.widget) action.setIcon(image) action.setToolTip(annotation) action.triggered.connect(lambda: self._exec_cmd(cmd)) button = QtGui.QToolButton() button.setAutoRaise(True) button.setDefaultAction(action) self.layout.addWidget(button)