本文整理汇总了Python中PyQt4.Qt.QToolButton.setMaximumWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QToolButton.setMaximumWidth方法的具体用法?Python QToolButton.setMaximumWidth怎么用?Python QToolButton.setMaximumWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QToolButton
的用法示例。
在下文中一共展示了QToolButton.setMaximumWidth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _createToolButtonWidget
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setMaximumWidth [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: makeButton
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setMaximumWidth [as 别名]
def makeButton(self, label, callback=None, width=None, icon=None):
btn = QToolButton(self)
# btn.setAutoRaise(True)
label and btn.setText(label)
icon and btn.setIcon(icon)
# btn = QPushButton(label,self)
# btn.setFlat(True)
if width:
btn.setMinimumWidth(width)
btn.setMaximumWidth(width)
if icon:
btn.setIcon(icon)
if callback:
QObject.connect(btn, SIGNAL("clicked()"), callback)
return btn
示例3: setupUi
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setMaximumWidth [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
#.........这里部分代码省略.........
示例4: StatusBar
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setMaximumWidth [as 别名]
class StatusBar(QStatusBar):
def __init__(self, win):
QStatusBar.__init__(self, win)
self.statusMsgLabel = QLabel()
self.statusMsgLabel.setMinimumWidth(200)
self.statusMsgLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)
self.addPermanentWidget(self.statusMsgLabel)
self.progressBar = QProgressBar(win)
self.progressBar.setMaximumWidth(250)
qt4todo("StatusBar.progressBar.setCenterIndicator(True)")
self.addPermanentWidget(self.progressBar)
self.progressBar.hide()
self.simAbortButton = QToolButton(win)
self.simAbortButton.setIcon(geticon("ui/actions/Simulation/Stopsign.png"))
self.simAbortButton.setMaximumWidth(32)
self.addPermanentWidget(self.simAbortButton)
self.connect(self.simAbortButton, SIGNAL("clicked()"), self.simAbort)
self.simAbortButton.hide()
self.dispbarLabel = QLabel(win)
# self.dispbarLabel.setFrameStyle( QFrame.Panel | QFrame.Sunken )
self.dispbarLabel.setText("Global display style:")
self.addPermanentWidget(self.dispbarLabel)
# Global display styles combobox
self.globalDisplayStylesComboBox = GlobalDisplayStylesComboBox(win)
self.addPermanentWidget(self.globalDisplayStylesComboBox)
# Selection lock button. It always displays the selection lock state
# and it is available to click.
self.selectionLockButton = QToolButton(win)
self.selectionLockButton.setDefaultAction(win.selectLockAction)
self.addPermanentWidget(self.selectionLockButton)
# Only use of this appears to be commented out in MWsemantics as of 2007/12/14
self.modebarLabel = QLabel(win)
self.addPermanentWidget(self.modebarLabel)
self.abortableCommands = {}
def makeCommandNameUnique(self, commandName):
index = 1
trial = commandName
while self.abortableCommands.has_key(trial):
trial = "%s [%d]" % (commandName, index)
index += 1
return trial
def addAbortableCommand(self, commandName, abortHandler):
uniqueCommandName = self.makeCommandNameUnique(commandName)
self.abortableCommands[uniqueCommandName] = abortHandler
return uniqueCommandName
def removeAbortableCommand(self, commandName):
del self.abortableCommands[commandName]
def simAbort(self):
"""
Slot for Abort button.
"""
if debug_flags.atom_debug and self.sim_abort_button_pressed: # bruce 060106
print "atom_debug: self.sim_abort_button_pressed is already True before we even put up our dialog"
# Added confirmation before aborting as part of fix to bug 915. Mark 050824.
# Bug 915 had to do with a problem if the user accidently hit the space bar or espace key,
# which would call this slot and abort the simulation. This should no longer be an issue here
# since we aren't using a dialog. I still like having this confirmation anyway.
# IMHO, it should be kept. Mark 060106.
ret = QMessageBox.warning(
self,
"Confirm",
"Please confirm you want to abort.\n",
"Confirm",
"Cancel",
"",
1, # The "default" button, when user presses Enter or Return (1 = Cancel)
1,
) # Escape (1= Cancel)
if ret == 0: # Confirmed
for abortHandler in self.abortableCommands.values():
abortHandler.pressed()
def show_indeterminate_progress(self):
value = self.progressBar.value()
self.progressBar.setValue(value)
def possibly_hide_progressbar_and_stop_button(self):
if len(self.abortableCommands) <= 0:
self.progressBar.reset()
self.progressBar.hide()
self.simAbortButton.hide()
def show_progressbar_and_stop_button(self, progressReporter, cmdname="<unknown command>", showElapsedTime=False):
"""
Display the statusbar's progressbar and stop button, and
update it based on calls to the progressReporter.
#.........这里部分代码省略.........
示例5: _updateModel
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setMaximumWidth [as 别名]
def _updateModel(self, what=SkyModel.UpdateAll, origin=None):
if origin is self or not what & (SkyModel.UpdateTags | SkyModel.UpdateGroupStyle):
return
model = self.model
self._setting_model = True; # to ignore cellChanged() signals (in valueChanged())
# _item_cb is a dict (with row,col keys) containing the widgets (CheckBoxes ComboBoxes) per each cell
self._item_cb = {}
# lists of "list" and "plot" checkboxes per each grouping (excepting the default grouping); each entry is an (row,col,item) tuple.
# used as argument to self._showControls()
self._list_controls = []
self._plot_controls = []
# list of selection callbacks (to which signals are connected)
self._callbacks = []
# set requisite number of rows,and start filling
self.table.setRowCount(len(model.groupings))
for irow, group in enumerate(model.groupings):
self.table.setItem(irow, 0, QTableWidgetItem(group.name))
if group is model.selgroup:
self._irow_selgroup = irow
# total # source in group: skip for "current"
if group is not model.curgroup:
self.table.setItem(irow, 1, QTableWidgetItem(str(group.total)))
# selection controls: skip for current and selection
if group not in (model.curgroup, model.selgroup):
btns = QWidget()
lo = QHBoxLayout(btns)
lo.setContentsMargins(0, 0, 0, 0)
lo.setSpacing(0)
# make selector buttons (depending on which group we're in)
if group is model.defgroup:
Buttons = (
("+", lambda src, grp=group: True, "select all sources"),
("-", lambda src, grp=group: False, "unselect all sources"))
else:
Buttons = (
("=", lambda src, grp=group: grp.func(src), "select only this grouping"),
("+", lambda src, grp=group: src.selected or grp.func(src), "add grouping to selection"),
("-", lambda src, grp=group: src.selected and not grp.func(src),
"remove grouping from selection"),
("&&", lambda src, grp=group: src.selected and grp.func(src),
"intersect selection with grouping"))
lo.addStretch(1)
for label, predicate, tooltip in Buttons:
btn = QToolButton(btns)
btn.setText(label)
btn.setMinimumWidth(24)
btn.setMaximumWidth(24)
btn.setToolTip(tooltip)
lo.addWidget(btn)
# add callback
QObject.connect(btn, SIGNAL("clicked()"), self._currier.curry(self.selectSources, predicate))
lo.addStretch(1)
self.table.setCellWidget(irow, 2, btns)
# "list" checkbox (not for current and selected groupings: these are always listed)
if group not in (model.curgroup, model.selgroup):
item = self._makeCheckItem("", group, "show_list")
self.table.setItem(irow, self.ColList, item)
item.setToolTip("""<P>If checked, sources in this grouping will be listed in the source table. If un-checked, sources will be
excluded from the table. If partially checked, then the default list/no list setting of "all sources" will be in effect.
</P>""")
# "plot" checkbox (not for the current grouping, since that's always plotted)
if group is not model.curgroup:
item = self._makeCheckItem("", group, "show_plot")
self.table.setItem(irow, self.ColPlot, item)
item.setToolTip("""<P>If checked, sources in this grouping will be included in the plot. If un-checked, sources will be
excluded from the plot. If partially checked, then the default plot/no plot setting of "all sources" will be in effect.
</P>""")
# custom style control
# for default, current and selected, this is just a text label
if group is model.defgroup:
item = QTableWidgetItem("default:")
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
item.setToolTip(
"""<P>This is the default plot style used for all sources for which a custom grouping style is not selected.</P>""")
self.table.setItem(irow, self.ColApply, item)
elif group is model.curgroup:
item = QTableWidgetItem("")
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
item.setToolTip("""<P>This is the plot style used for the highlighted source, if any.</P>""")
self.table.setItem(irow, self.ColApply, item)
elif group is model.selgroup:
item = QTableWidgetItem("")
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
item.setToolTip("""<P>This is the plot style used for the currently selected sources.</P>""")
self.table.setItem(irow, self.ColApply, item)
# for the rest, a combobox with custom priorities
else:
cb = QComboBox()
cb.addItems(["default"] + ["custom %d" % p for p in range(1, 10)])
index = max(0, min(group.style.apply, 9))
# dprint(0,group.name,"apply",index)
cb.setCurrentIndex(index)
QObject.connect(cb, SIGNAL("activated(int)"),
self._currier.xcurry(self._valueChanged, (irow, self.ColApply)))
self.table.setCellWidget(irow, self.ColApply, cb)
cb.setToolTip("""<P>This controls whether sources within this group are plotted with a customized
plot style. Customized styles have numeric priority; if a source belongs to multiple groups, then
the style with the lowest priority takes precedence.<P>""")
# attribute comboboxes
for icol, attr in self.AttrByCol.items():
#.........这里部分代码省略.........