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)
python类QToolButton()的实例源码
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)