我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用PySide.QtGui.QToolButton()。
def __init__(self, parent=None): super(self.__class__, self).__init__(parent=parent) self.setupUi(self) self.horizontalLayout = QtGui.QHBoxLayout(self.buttonLabel) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.toolButton = QtGui.QToolButton(self) self.toolButton.setAutoRaise(True) self.toolButton.setArrowType(QtCore.Qt.DownArrow) self.horizontalLayout.addWidget(self.toolButton)
def __init__(self, sandbox, parent=None): QtGui.QToolButton.__init__(self, parent) menu = self.SourcesAddMenu(sandbox, self, 'Availables sources') self.setText('Add Source') self.setMenu(menu) self.setIcon(self.style().standardPixmap( QtGui.QStyle.SP_FileDialogDetailedView)) self.setPopupMode(QtGui.QToolButton.InstantPopup) self.setToolButtonStyle(QtCore.Qt.ToolButtonTextOnly)
def setupToolButton(self, icon_name, name): ico = Icon(icon_name) self.toolButton = QtGui.QToolButton(None) self.toolButton.setIcon(ico) self.toolButton.setText(name) if self.SHORTCUT is not None: self.toolButton.setShortcut(self.SHORTCUT) if self.TOOLTIP is not None: self.toolButton.setToolTip(self.TOOLTIP)