本文整理汇总了Python中PyQt4.Qt.QToolButton.setToolButtonStyle方法的典型用法代码示例。如果您正苦于以下问题:Python QToolButton.setToolButtonStyle方法的具体用法?Python QToolButton.setToolButtonStyle怎么用?Python QToolButton.setToolButtonStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QToolButton
的用法示例。
在下文中一共展示了QToolButton.setToolButtonStyle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _createToolButtonWidget
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setToolButtonStyle [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: SliderControl
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setToolButtonStyle [as 别名]
class SliderControl(QObject):
"""This class implements a slider control for a colormap"""
def __init__(self, name, value, minval, maxval, step, format="%s: %.1f"):
QObject.__init__(self)
self.name, self.value, self.minval, self.maxval, self.step, self.format = \
name, value, minval, maxval, step, format
self._default = value
self._wlabel = None
def makeControlWidgets(self, parent, gridlayout, row, column):
toprow = QWidget(parent)
gridlayout.addWidget(toprow, row * 2, column)
top_lo = QHBoxLayout(toprow)
top_lo.setContentsMargins(0, 0, 0, 0)
self._wlabel = QLabel(self.format % (self.name, self.value), toprow)
top_lo.addWidget(self._wlabel)
self._wreset = QToolButton(toprow)
self._wreset.setText("reset")
self._wreset.setToolButtonStyle(Qt.ToolButtonTextOnly)
self._wreset.setAutoRaise(True)
self._wreset.setEnabled(self.value != self._default)
QObject.connect(self._wreset, SIGNAL("clicked()"), self._resetValue)
top_lo.addWidget(self._wreset)
self._wslider = QwtSlider(parent)
# This works around a stupid bug in QwtSliders -- see comments on histogram zoom wheel above
self._wslider_timer = QTimer(parent)
self._wslider_timer.setSingleShot(True)
self._wslider_timer.setInterval(500)
QObject.connect(self._wslider_timer, SIGNAL("timeout()"), self.setValue)
gridlayout.addWidget(self._wslider, row * 2 + 1, column)
self._wslider.setRange(self.minval, self.maxval)
self._wslider.setStep(self.step)
self._wslider.setValue(self.value)
self._wslider.setTracking(False)
QObject.connect(self._wslider, SIGNAL("valueChanged(double)"), self.setValue)
QObject.connect(self._wslider, SIGNAL("sliderMoved(double)"), self._previewValue)
def _resetValue(self):
self._wslider.setValue(self._default)
self.setValue(self._default)
def setValue(self, value=None, notify=True):
# only update widgets if already created
self.value = value
if self._wlabel is not None:
if value is None:
self.value = value = self._wslider.value()
self._wreset.setEnabled(value != self._default)
self._wlabel.setText(self.format % (self.name, self.value))
# stop timer if being called to finalize the change in value
if notify:
self._wslider_timer.stop()
self.emit(SIGNAL("valueChanged"), self.value)
def _previewValue(self, value):
self.setValue(notify=False)
self._wslider_timer.start(500)
self.emit(SIGNAL("valueMoved"), self.value)
示例3: __init__
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setToolButtonStyle [as 别名]
def __init__(self, parent):
QWidget.__init__(self, parent)
self._layout = l = QHBoxLayout()
self.setLayout(self._layout)
self._layout.setContentsMargins(0,5,0,0)
x = QToolButton(self)
x.setText(_('Vi&rtual Library'))
x.setIcon(QIcon(I('lt.png')))
x.setObjectName("virtual_library")
x.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
l.addWidget(x)
parent.virtual_library = x
x = QToolButton(self)
x.setIcon(QIcon(I('minus.png')))
x.setObjectName('clear_vl')
l.addWidget(x)
x.setVisible(False)
x.setToolTip(_('Close the Virtual Library'))
parent.clear_vl = x
x = QLabel(self)
x.setObjectName("search_count")
l.addWidget(x)
parent.search_count = x
x.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
parent.advanced_search_button = x = QToolButton(self)
parent.advanced_search_toggle_action = ac = QAction(parent)
parent.addAction(ac)
parent.keyboard.register_shortcut('advanced search toggle',
_('Advanced search'), default_keys=(_("Shift+Ctrl+F"),),
action=ac)
ac.triggered.connect(x.click)
x.setIcon(QIcon(I('search.png')))
l.addWidget(x)
x.setToolTip(_("Advanced search"))
x = parent.search = SearchBox2(self)
x.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
x.setObjectName("search")
x.setToolTip(_("<p>Search the list of books by title, author, publisher, "
"tags, comments, etc.<br><br>Words separated by spaces are ANDed"))
x.setMinimumContentsLength(10)
l.addWidget(x)
self.search_button = QToolButton()
self.search_button.setToolButtonStyle(Qt.ToolButtonTextOnly)
self.search_button.setText(_('&Go!'))
l.addWidget(self.search_button)
self.search_button.setSizePolicy(QSizePolicy.Minimum,
QSizePolicy.Minimum)
self.search_button.clicked.connect(parent.do_search_button)
self.search_button.setToolTip(
_('Do Quick Search (you can also press the Enter key)'))
x = parent.clear_button = QToolButton(self)
x.setIcon(QIcon(I('clear_left.png')))
x.setObjectName("clear_button")
l.addWidget(x)
x.setToolTip(_("Reset Quick Search"))
x = parent.highlight_only_button = QToolButton(self)
x.setIcon(QIcon(I('arrow-down.png')))
l.addWidget(x)
x = parent.saved_search = SavedSearchBox(self)
x.setMaximumSize(QSize(150, 16777215))
x.setMinimumContentsLength(10)
x.setObjectName("saved_search")
l.addWidget(x)
x = parent.copy_search_button = QToolButton(self)
x.setIcon(QIcon(I("search_copy_saved.png")))
x.setObjectName("copy_search_button")
l.addWidget(x)
x.setToolTip(_("Copy current search text (instead of search name)"))
x = parent.save_search_button = QToolButton(self)
x.setIcon(QIcon(I("search_add_saved.png")))
x.setObjectName("save_search_button")
l.addWidget(x)
示例4: __init__
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setToolButtonStyle [as 别名]
#.........这里部分代码省略.........
lo1.setColumnStretch(1, 1)
self._wlogcycles_label = QLabel("Log cycles: ", self)
lo1.addWidget(self._wlogcycles_label, 0, 1)
# self._wlogcycles = QwtWheel(self)
# self._wlogcycles.setTotalAngle(360)
self._wlogcycles = QwtSlider(self)
self._wlogcycles.setToolTip(
"""<P>Use this to change the log-base for the logarithmic intensity transfer function (ITF).</P>""")
# This works around a stupid bug in QwtSliders -- see comments on histogram zoom wheel above
self._wlogcycles_timer = QTimer(self)
self._wlogcycles_timer.setSingleShot(True)
self._wlogcycles_timer.setInterval(500)
QObject.connect(self._wlogcycles_timer, SIGNAL("timeout()"), self._setIntensityLogCycles)
lo1.addWidget(self._wlogcycles, 1, 1)
self._wlogcycles.setRange(1., 10)
self._wlogcycles.setStep(0.1)
self._wlogcycles.setTracking(False)
QObject.connect(self._wlogcycles, SIGNAL("valueChanged(double)"), self._setIntensityLogCycles)
QObject.connect(self._wlogcycles, SIGNAL("sliderMoved(double)"), self._previewIntensityLogCycles)
self._updating_imap = False
# lock intensity map
lo1 = QHBoxLayout()
lo1.setContentsMargins(0, 0, 0, 0)
lo0.addLayout(lo1, 0)
# lo1.addWidget(QLabel("Lock range accross",self))
wlock = QCheckBox("Lock display range", self)
wlock.setToolTip("""<P>If checked, then the intensity range will be locked. The ranges of all locked images
change simultaneously.</P>""")
lo1.addWidget(wlock)
wlockall = QToolButton(self)
wlockall.setIcon(pixmaps.locked.icon())
wlockall.setText("Lock all to this")
wlockall.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
wlockall.setAutoRaise(True)
wlockall.setToolTip("""<P>Click this to lock together the intensity ranges of all images.</P>""")
lo1.addWidget(wlockall)
wunlockall = QToolButton(self)
wunlockall.setIcon(pixmaps.unlocked.icon())
wunlockall.setText("Unlock all")
wunlockall.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
wunlockall.setAutoRaise(True)
wunlockall.setToolTip("""<P>Click this to unlock the intensity ranges of all images.</P>""")
lo1.addWidget(wunlockall)
wlock.setChecked(self._rc.isDisplayRangeLocked())
QObject.connect(wlock, SIGNAL("clicked(bool)"), self._rc.lockDisplayRange)
QObject.connect(wlockall, SIGNAL("clicked()"),
self._currier.curry(self._imgman.lockAllDisplayRanges, self._rc))
QObject.connect(wunlockall, SIGNAL("clicked()"), self._imgman.unlockAllDisplayRanges)
QObject.connect(self._rc, SIGNAL("displayRangeLocked"), wlock.setChecked)
# self._wlock_imap_axis = [ QCheckBox(name,self) for iaxis,name,labels in sliced_axes ]
# for iw,w in enumerate(self._wlock_imap_axis):
# QObject.connect(w,SIGNAL("toggled(bool)"),self._currier.curry(self._rc.lockDisplayRangeForAxis,iw))
# lo1.addWidget(w,0)
lo1.addStretch(1)
# lo0.addWidget(Separator(self,"Colourmap"))
# color bar
self._colorbar = QwtPlot(self)
lo0.addWidget(self._colorbar)
self._colorbar.setAutoDelete(False)
self._colorbar.setMinimumHeight(32)
self._colorbar.enableAxis(QwtPlot.yLeft, False)
self._colorbar.enableAxis(QwtPlot.xBottom, False)
# color plot
示例5: setupUi
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setToolButtonStyle [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
#.........这里部分代码省略.........