本文整理汇总了Python中PyQt4.Qt.QToolButton.setIconSize方法的典型用法代码示例。如果您正苦于以下问题:Python QToolButton.setIconSize方法的具体用法?Python QToolButton.setIconSize怎么用?Python QToolButton.setIconSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QToolButton
的用法示例。
在下文中一共展示了QToolButton.setIconSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _createToolButton
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setIconSize [as 别名]
def _createToolButton(self, widgetParams):
"""
Returns a tool button created using the custom parameters.
@param widgetParams: A list containing tool button parameters.
@type widgetParams: list
@see: L{self._createWidgetUsingParameters} where this method is called.
"""
buttonSize = QSize(32, 32) #@ FOR TEST ONLY
buttonParams = list(widgetParams)
buttonId = buttonParams[1]
buttonText = buttonParams[2]
buttonIconPath = buttonParams[3]
buttonToolTip = buttonParams[4]
buttonShortcut = buttonParams[5]
button = QToolButton(self)
button.setText(buttonText)
if buttonIconPath:
buttonIcon = geticon(buttonIconPath)
if not buttonIcon.isNull():
button.setIcon(buttonIcon)
button.setIconSize(QSize(22, 22))
button.setToolTip(buttonToolTip)
if buttonShortcut:
button.setShortcut(buttonShortcut)
button.setFixedSize(buttonSize) #@ Currently fixed to 32 x 32.
button.setCheckable(True)
return button
示例2: FormatsManager
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setIconSize [as 别名]
class FormatsManager(QWidget):
def __init__(self, parent, copy_fmt):
QWidget.__init__(self, parent)
self.dialog = parent
self.copy_fmt = copy_fmt
self.changed = False
self.l = l = QGridLayout()
self.setLayout(l)
self.cover_from_format_button = QToolButton(self)
self.cover_from_format_button.setToolTip(
_('Set the cover for the book from the selected format'))
self.cover_from_format_button.setIcon(QIcon(I('book.png')))
self.cover_from_format_button.setIconSize(QSize(32, 32))
self.metadata_from_format_button = QToolButton(self)
self.metadata_from_format_button.setIcon(QIcon(I('edit_input.png')))
self.metadata_from_format_button.setIconSize(QSize(32, 32))
self.metadata_from_format_button.setToolTip(
_('Set metadata for the book from the selected format'))
self.add_format_button = QToolButton(self)
self.add_format_button.setIcon(QIcon(I('add_book.png')))
self.add_format_button.setIconSize(QSize(32, 32))
self.add_format_button.clicked.connect(self.add_format)
self.add_format_button.setToolTip(
_('Add a format to this book'))
self.remove_format_button = QToolButton(self)
self.remove_format_button.setIcon(QIcon(I('trash.png')))
self.remove_format_button.setIconSize(QSize(32, 32))
self.remove_format_button.clicked.connect(self.remove_format)
self.remove_format_button.setToolTip(
_('Remove the selected format from this book'))
self.formats = FormatList(self)
self.formats.setAcceptDrops(True)
self.formats.formats_dropped.connect(self.formats_dropped)
self.formats.restore_fmt.connect(self.restore_fmt)
self.formats.delete_format.connect(self.remove_format)
self.formats.itemDoubleClicked.connect(self.show_format)
self.formats.setDragDropMode(self.formats.DropOnly)
self.formats.setIconSize(QSize(32, 32))
self.formats.setMaximumWidth(200)
l.addWidget(self.cover_from_format_button, 0, 0, 1, 1)
l.addWidget(self.metadata_from_format_button, 2, 0, 1, 1)
l.addWidget(self.add_format_button, 0, 2, 1, 1)
l.addWidget(self.remove_format_button, 2, 2, 1, 1)
l.addWidget(self.formats, 0, 1, 3, 1)
self.temp_files = []
def initialize(self, db, id_):
self.changed = False
self.formats.clear()
exts = db.formats(id_, index_is_id=True)
self.original_val = set([])
if exts:
exts = exts.split(',')
for ext in exts:
if not ext:
ext = ''
size = db.sizeof_format(id_, ext, index_is_id=True)
timestamp = db.format_last_modified(id_, ext)
if size is None:
continue
Format(self.formats, ext, size, timestamp=timestamp)
self.original_val.add(ext.lower())
def commit(self, db, id_):
if not self.changed:
return True
old_extensions, new_extensions, paths = set(), set(), {}
for row in range(self.formats.count()):
fmt = self.formats.item(row)
ext, path = fmt.ext.lower(), fmt.path
if 'unknown' in ext.lower():
ext = None
if path:
new_extensions.add(ext)
paths[ext] = path
else:
old_extensions.add(ext)
for ext in new_extensions:
with SpooledTemporaryFile(SPOOL_SIZE) as spool:
with open(paths[ext], 'rb') as f:
shutil.copyfileobj(f, spool)
spool.seek(0)
db.add_format(id_, ext, spool, notify=False,
index_is_id=True)
dbfmts = db.formats(id_, index_is_id=True)
db_extensions = set([f.lower() for f in (dbfmts.split(',') if dbfmts
else [])])
extensions = new_extensions.union(old_extensions)
for ext in db_extensions:
if ext not in extensions and ext in self.original_val:
db.remove_format(id_, ext, notify=False, index_is_id=True)
#.........这里部分代码省略.........
示例3: setupUi
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setIconSize [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: PM_Dialog
# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setIconSize [as 别名]
#.........这里部分代码省略.........
def _createTopRowBtns(self):
"""
Creates the Done, Cancel, Preview, Restore Defaults and What's This
buttons row at the top of the Property Manager.
"""
topBtnSize = QSize(22, 22) # button images should be 16 x 16, though.
# Main "button group" widget (but it is not a QButtonGroup).
self.pmTopRowBtns = QHBoxLayout()
# This QHBoxLayout is (probably) not necessary. Try using just the frame
# for the foundation. I think it should work. Mark 2007-05-30
# Horizontal spacer
horizontalSpacer = QSpacerItem(1, 1,
QSizePolicy.Expanding,
QSizePolicy.Minimum)
# Widget containing all the buttons.
self.topRowBtnsContainer = QWidget()
# Create Hbox layout for main frame.
topRowBtnsHLayout = QHBoxLayout(self.topRowBtnsContainer)
topRowBtnsHLayout.setMargin(PM_TOPROWBUTTONS_MARGIN)
topRowBtnsHLayout.setSpacing(PM_TOPROWBUTTONS_SPACING)
# Set to True to center align the buttons in the PM
if False: # Left aligns the buttons.
topRowBtnsHLayout.addItem(horizontalSpacer)
# Done (OK) button.
self.done_btn = QToolButton(self.topRowBtnsContainer)
self.done_btn.setIcon(
geticon("ui/actions/Properties Manager/Done_16x16.png"))
self.done_btn.setIconSize(topBtnSize)
self.done_btn.setAutoRaise(True)
self.connect(self.done_btn,
SIGNAL("clicked()"),
self.doneButtonClicked)
self.done_btn.setToolTip("Done")
topRowBtnsHLayout.addWidget(self.done_btn)
# Cancel (Abort) button.
self.cancel_btn = QToolButton(self.topRowBtnsContainer)
self.cancel_btn.setIcon(
geticon("ui/actions/Properties Manager/Abort_16x16.png"))
self.cancel_btn.setIconSize(topBtnSize)
self.cancel_btn.setAutoRaise(True)
self.connect(self.cancel_btn,
SIGNAL("clicked()"),
self.cancelButtonClicked)
self.cancel_btn.setToolTip("Cancel")
topRowBtnsHLayout.addWidget(self.cancel_btn)
#@ abort_btn deprecated. We still need it because modes use it.
self.abort_btn = self.cancel_btn
# Restore Defaults button.
self.restore_defaults_btn = QToolButton(self.topRowBtnsContainer)
self.restore_defaults_btn.setIcon(
geticon("ui/actions/Properties Manager/Restore_16x16.png"))
self.restore_defaults_btn.setIconSize(topBtnSize)
self.restore_defaults_btn.setAutoRaise(True)
self.connect(self.restore_defaults_btn,
SIGNAL("clicked()"),