本文整理汇总了Python中PyQt4.Qt.QToolButton.setPalette方法的典型用法代码示例。如果您正苦于以下问题:Python QToolButton.setPalette方法的具体用法?Python QToolButton.setPalette怎么用?Python QToolButton.setPalette使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QToolButton
的用法示例。
在下文中一共展示了QToolButton.setPalette方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _createToolButtonWidget
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setPalette [as 别名]
def _createToolButtonWidget(self, parent):
"""
@see: self.createWidget()
"""
btn = QToolButton(parent)
btn.setAutoFillBackground(True)
btn.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
btn.setMinimumWidth(75)
btn.setMaximumWidth(75)
btn.setMinimumHeight(62)
btn.setAutoRaise(True)
btn.setCheckable(True)
btn.setDefaultAction(self)
text = truncateText(self.text())
btn.setText(text)
if self._toolButtonPalette:
btn.setPalette(self._toolButtonPalette)
#@@@ ninad070125 The following function
#adds a newline character after each word in toolbutton text.
#but the changes are reflected only on 'mode' toolbuttons
#on the flyout toolbar (i.e.only Checkable buttons..don't know
#why. Disabling its use for now.
debug_wrapText = False
if debug_wrapText:
text = wrapToolButtonText(action.text())
if text:
action.setText(text)
return btn
示例2: setupUi
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setPalette [as 别名]
def setupUi(self):
"""
Setup the UI for the command toolbar.
"""
#ninad 070123 : It's important to set the Vertical size policy of the
# cmd toolbar widget. otherwise the flyout QToolbar messes up the
#layout (makes the command toolbar twice as big)
#I have set the vertical policy as fixed. Works fine. There are some
# MainWindow resizing problems for but those are not due to this
#size policy AFAIK
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
layout_cmdtoolbar = QHBoxLayout(self)
layout_cmdtoolbar.setMargin(2)
layout_cmdtoolbar.setSpacing(2)
#See comment at the top for details about this flag
if DEFINE_CONTROL_AREA_AS_A_QWIDGET:
self.cmdToolbarControlArea = QWidget(self)
else:
self.cmdToolbarControlArea = QToolBar_WikiHelp(self)
self.cmdToolbarControlArea.setAutoFillBackground(True)
self.ctrlAreaPalette = self.getCmdMgrCtrlAreaPalette()
self.cmdToolbarControlArea.setPalette(self.ctrlAreaPalette)
self.cmdToolbarControlArea.setMinimumHeight(62)
self.cmdToolbarControlArea.setMinimumWidth(380)
self.cmdToolbarControlArea.setSizePolicy(QSizePolicy.Fixed,
QSizePolicy.Fixed)
#See comment at the top for details about this flag
if DEFINE_CONTROL_AREA_AS_A_QWIDGET:
layout_controlArea = QHBoxLayout(self.cmdToolbarControlArea)
layout_controlArea.setMargin(0)
layout_controlArea.setSpacing(0)
self.cmdButtonGroup = QButtonGroup()
btn_index = 0
for name in ('Build', 'Insert', 'Tools', 'Move', 'Simulation'):
btn = QToolButton(self.cmdToolbarControlArea)
btn.setObjectName(name)
btn.setMinimumWidth(75)
btn.setMaximumWidth(75)
btn.setMinimumHeight(62)
btn.setAutoRaise(True)
btn.setCheckable(True)
btn.setAutoExclusive(True)
iconpath = "ui/actions/Command Toolbar/ControlArea/" + name + ".png"
btn.setIcon(geticon(iconpath))
btn.setIconSize(QSize(22, 22))
btn.setText(name)
btn.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
btn.setPalette(self.ctrlAreaPalette)
self.cmdButtonGroup.addButton(btn, btn_index)
btn_index += 1
#See comment at the top for details about this flag
if DEFINE_CONTROL_AREA_AS_A_QWIDGET:
layout_controlArea.addWidget(btn)
else:
self.cmdToolbarControlArea.layout().addWidget(btn)
#following has issues. so not adding widget directly to the
#toolbar. (instead adding it in its layout)-- ninad 070124
##self.cmdToolbarControlArea.addWidget(btn)
layout_cmdtoolbar.addWidget(self.cmdToolbarControlArea)
#Flyout Toolbar in the command toolbar
self.flyoutToolBar = FlyoutToolBar(self)
layout_cmdtoolbar.addWidget(self.flyoutToolBar)
#ninad 070116: Define a spacer item. It will have the exact geometry
# as that of the flyout toolbar. it is added to the command toolbar
# layout only when the Flyout Toolbar is hidden. It is required
# to keep the 'Control Area' widget fixed in its place (otherwise,
#after hiding the flyout toolbar, the layout adjusts the position of
#remaining widget items)
self.spacerItem = QSpacerItem(0,
0,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Minimum)
self.spacerItem.setGeometry = self.flyoutToolBar.geometry()
for btn in self.cmdButtonGroup.buttons():
if str(btn.objectName()) == 'Build':
btn.setMenu(self.win.buildStructuresMenu)
btn.setPopupMode(QToolButton.MenuButtonPopup)
btn.setToolTip("Build Commands")
whatsThisTextForCommandToolbarBuildButton(btn)
if str(btn.objectName()) == 'Insert':
btn.setMenu(self.win.insertMenu)
btn.setPopupMode(QToolButton.MenuButtonPopup)
btn.setToolTip("Insert Commands")
whatsThisTextForCommandToolbarInsertButton(btn)
if str(btn.objectName()) == 'Tools':
#fyi: cmd stands for 'command toolbar' - ninad070406
#.........这里部分代码省略.........