本文整理汇总了Python中PyQt4.Qt.QFrame.setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QFrame.setSizePolicy方法的具体用法?Python QFrame.setSizePolicy怎么用?Python QFrame.setSizePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QFrame
的用法示例。
在下文中一共展示了QFrame.setSizePolicy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setSizePolicy [as 别名]
def __init__(self, parent, config_name=None, buttons=[], *args):
"""Creates dialog.
'config_name' is used to get/set default window size from Config object
'buttons' can be a list of names or (QPixmapWrapper,name[,tooltip]) tuples to provide
custom buttons at the bottom of the dialog. When a button is clicked, the dialog
emits SIGNAL("name").
A "Close" button is always provided, this simply hides the dialog.
"""
QDialog.__init__(self, parent, *args)
self.setModal(False)
lo = QVBoxLayout(self)
# create viewer
self.label = QLabel(self)
self.label.setMargin(5)
self.label.setWordWrap(True)
lo.addWidget(self.label)
self.label.hide()
self.viewer = QTextBrowser(self)
lo.addWidget(self.viewer)
# self.viewer.setReadOnly(True)
self.viewer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
QObject.connect(self.viewer, SIGNAL("anchorClicked(const QUrl &)"), self._urlClicked)
self._source = None
lo.addSpacing(5)
# create button bar
btnfr = QFrame(self)
btnfr.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
# btnfr.setMargin(5)
lo.addWidget(btnfr)
lo.addSpacing(5)
btnfr_lo = QHBoxLayout(btnfr)
btnfr_lo.setMargin(5)
# add user buttons
self._user_buttons = {}
for name in buttons:
if isinstance(name, str):
btn = QPushButton(name, btnfr)
elif isinstance(name, (list, tuple)):
if len(name) < 3:
pixmap, name = name
tip = None
else:
pixmap, name, tip = name
btn = QPushButton(pixmap.icon(), name, btnfr)
if tip:
btn.setToolTip(tip)
self._user_buttons[name] = btn
btn._clicked = Kittens.utils.curry(self.emit, SIGNAL(name))
self.connect(btn, SIGNAL("clicked()"), btn._clicked)
btnfr_lo.addWidget(btn, 1)
# add a Close button
btnfr_lo.addStretch(100)
closebtn = QPushButton(pixmaps.grey_round_cross.icon(), "Close", btnfr)
self.connect(closebtn, SIGNAL("clicked()"), self.hide)
btnfr_lo.addWidget(closebtn, 1)
# resize selves
self.config_name = config_name or "html-viewer"
width = Config.getint('%s-width' % self.config_name, 512)
height = Config.getint('%s-height' % self.config_name, 512)
self.resize(QSize(width, height))