本文整理汇总了Python中PyQt4.Qt.QToolButton.setPopupMode方法的典型用法代码示例。如果您正苦于以下问题:Python QToolButton.setPopupMode方法的具体用法?Python QToolButton.setPopupMode怎么用?Python QToolButton.setPopupMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QToolButton
的用法示例。
在下文中一共展示了QToolButton.setPopupMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setupUi
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setPopupMode [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
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setPopupMode [as 别名]
#.........这里部分代码省略.........
self._range_validator = FloatValidator(self)
self._wrange = QLineEdit(self), QLineEdit(self)
self._wrange[0].setToolTip("""<P>This is the low end of the intensity range.</P>""")
self._wrange[1].setToolTip("""<P>This is the high end of the intensity range.</P>""")
for w in self._wrange:
w.setValidator(self._range_validator)
QObject.connect(w, SIGNAL("editingFinished()"), self._changeDisplayRange)
lo1.addWidget(QLabel("low:", self), 0)
lo1.addWidget(self._wrange[0], 1)
self._wrangeleft0 = self.makeButton("\u21920", self._setZeroLeftLimit, width=32)
self._wrangeleft0.setToolTip("""<P>Click this to set the low end of the intensity range to 0.</P>""")
lo1.addWidget(self._wrangeleft0, 0)
lo1.addSpacing(8)
lo1.addWidget(QLabel("high:", self), 0)
lo1.addWidget(self._wrange[1], 1)
lo1.addSpacing(8)
self._wrange_full = self.makeButton(None, self._setHistDisplayRange, icon=pixmaps.intensity_graph.icon())
lo1.addWidget(self._wrange_full)
self._wrange_full.setToolTip(
"""<P>Click this to reset the intensity range to the current extent of the histogram plot.</P>""")
# add menu for display range
range_menu = QMenu(self)
wrange_menu = QToolButton(self)
wrange_menu.setText("Reset to")
wrange_menu.setToolTip("""<P>Use this to reset the intensity range to various pre-defined settings.</P>""")
lo1.addWidget(wrange_menu)
self._qa_range_full = range_menu.addAction(pixmaps.full_range.icon(), "Full subset",
self._rc.resetSubsetDisplayRange)
self._qa_range_hist = range_menu.addAction(pixmaps.intensity_graph.icon(), "Current histogram limits",
self._setHistDisplayRange)
for percent in (99.99, 99.9, 99.5, 99, 98, 95):
range_menu.addAction("%g%%" % percent, self._currier.curry(self._changeDisplayRangeToPercent, percent))
wrange_menu.setMenu(range_menu)
wrange_menu.setPopupMode(QToolButton.InstantPopup)
lo1 = QGridLayout()
lo1.setContentsMargins(0, 0, 0, 0)
lo0.addLayout(lo1, 0)
self._wimap = QComboBox(self)
lo1.addWidget(QLabel("Intensity policy:", self), 0, 0)
lo1.addWidget(self._wimap, 1, 0)
self._wimap.addItems(rc.getIntensityMapNames())
QObject.connect(self._wimap, SIGNAL("currentIndexChanged(int)"), self._rc.setIntensityMapNumber)
self._wimap.setToolTip("""<P>Use this to change the type of the intensity transfer function (ITF).</P>""")
# log cycles control
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
示例3: ImageController
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setPopupMode [as 别名]
class ImageController(QFrame):
"""An ImageController is a widget for controlling the display of one image.
It can emit the following signals from the image:
raise raise button was clicked
center center-on-image option was selected
unload unload option was selected
slice image slice has changed, need to redraw (emitted by SkyImage automatically)
repaint image display range or colormap has changed, need to redraw (emitted by SkyImage automatically)
"""
def __init__(self, image, parent, imgman, name=None, save=False):
QFrame.__init__(self, parent)
self.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
# init state
self.image = image
self._imgman = imgman
self._currier = PersistentCurrier()
self._control_dialog = None
# create widgets
self._lo = lo = QHBoxLayout(self)
lo.setContentsMargins(0, 0, 0, 0)
lo.setSpacing(2)
# raise button
self._wraise = QToolButton(self)
lo.addWidget(self._wraise)
self._wraise.setIcon(pixmaps.raise_up.icon())
self._wraise.setAutoRaise(True)
self._can_raise = False
QObject.connect(self._wraise, SIGNAL("clicked()"), self._raiseButtonPressed)
self._wraise.setToolTip("""<P>Click here to raise this image above other images. Hold the button down briefly to
show a menu of image operations.</P>""")
# center label
self._wcenter = QLabel(self)
self._wcenter.setPixmap(pixmaps.center_image.pm())
self._wcenter.setToolTip(
"<P>The plot is currently centered on (the reference pixel %d,%d) of this image.</P>" % self.image.referencePixel())
lo.addWidget(self._wcenter)
# name/filename label
self.name = image.name
self._wlabel = QLabel(self.name, self)
self._number = 0
self.setName(self.name)
self._wlabel.setToolTip("%s %s" % (image.filename, "\u00D7".join(map(str, image.data().shape))))
lo.addWidget(self._wlabel, 1)
# if 'save' is specified, create a "save" button
if save:
self._wsave = QToolButton(self)
lo.addWidget(self._wsave)
self._wsave.setText("save")
self._wsave.setAutoRaise(True)
self._save_dir = save if isinstance(save, str) else "."
QObject.connect(self._wsave, SIGNAL("clicked()"), self._saveImage)
self._wsave.setToolTip("""<P>Click here to write this image to a FITS file.</P>""")
# render control
dprint(2, "creating RenderControl")
self._rc = RenderControl(image, self)
dprint(2, "done")
# selectors for extra axes
self._wslicers = []
curslice = self._rc.currentSlice(); # this may be loaded from config, so not necessarily 0
for iextra, axisname, labels in self._rc.slicedAxes():
if axisname.upper() not in ["STOKES", "COMPLEX"]:
lbl = QLabel("%s:" % axisname, self)
lo.addWidget(lbl)
else:
lbl = None
slicer = QComboBox(self)
self._wslicers.append(slicer)
lo.addWidget(slicer)
slicer.addItems(labels)
slicer.setToolTip("""<P>Selects current slice along the %s axis.</P>""" % axisname)
slicer.setCurrentIndex(curslice[iextra])
QObject.connect(slicer, SIGNAL("activated(int)"), self._currier.curry(self._rc.changeSlice, iextra))
# min/max display ranges
lo.addSpacing(5)
self._wrangelbl = QLabel(self)
lo.addWidget(self._wrangelbl)
self._minmaxvalidator = FloatValidator(self)
self._wmin = QLineEdit(self)
self._wmax = QLineEdit(self)
width = self._wmin.fontMetrics().width("1.234567e-05")
for w in self._wmin, self._wmax:
lo.addWidget(w, 0)
w.setValidator(self._minmaxvalidator)
w.setMaximumWidth(width)
w.setMinimumWidth(width)
QObject.connect(w, SIGNAL("editingFinished()"), self._changeDisplayRange)
# full-range button
self._wfullrange = QToolButton(self)
lo.addWidget(self._wfullrange, 0)
self._wfullrange.setIcon(pixmaps.zoom_range.icon())
self._wfullrange.setAutoRaise(True)
QObject.connect(self._wfullrange, SIGNAL("clicked()"), self.renderControl().resetSubsetDisplayRange)
rangemenu = QMenu(self)
rangemenu.addAction(pixmaps.full_range.icon(), "Full subset", self.renderControl().resetSubsetDisplayRange)
for percent in (99.99, 99.9, 99.5, 99, 98, 95):
rangemenu.addAction("%g%%" % percent, self._currier.curry(self._changeDisplayRangeToPercent, percent))
self._wfullrange.setPopupMode(QToolButton.DelayedPopup)
self._wfullrange.setMenu(rangemenu)
# update widgets from current display range
#.........这里部分代码省略.........