本文整理汇总了Python中PyQt4.Qt.QFrame类的典型用法代码示例。如果您正苦于以下问题:Python QFrame类的具体用法?Python QFrame怎么用?Python QFrame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QFrame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent, closeButton=True):
QFrame.__init__(self, parent)
self.setMaximumSize(QSize(9999999,22))
self.setObjectName("windowTitle")
self.hboxlayout = QHBoxLayout(self)
self.hboxlayout.setSpacing(0)
self.hboxlayout.setContentsMargins(0,0,4,0)
self.label = QLabel(self)
self.label.setObjectName("label")
self.label.setStyleSheet("padding-left:4px; font:bold 11px; color: #FFFFFF;")
self.hboxlayout.addWidget(self.label)
spacerItem = QSpacerItem(40,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
self.hboxlayout.addItem(spacerItem)
if closeButton:
self.pushButton = QPushButton(self)
self.pushButton.setFocusPolicy(Qt.NoFocus)
self.pushButton.setObjectName("pushButton")
self.pushButton.setStyleSheet("font:bold;")
self.pushButton.setText("X")
self.hboxlayout.addWidget(self.pushButton)
self.dragPosition = None
self.mainwidget = self.parent()
self.setStyleSheet("""
QFrame#windowTitle {background-color:#222222;color:#FFF;}
""")
# Initial position to top left
self.dragPosition = self.mainwidget.frameGeometry().topLeft()
示例2: __init__
def __init__(self, horizontal=False, size=48, parent=None):
QFrame.__init__(self, parent)
if horizontal:
size = 24
self.pi = ProgressIndicator(self, size)
self._jobs = QLabel('<b>'+_('Jobs:')+' 0')
self._jobs.mouseReleaseEvent = self.mouseReleaseEvent
self.shortcut = _('Shift+Alt+J')
if horizontal:
self.setLayout(QHBoxLayout())
self.layout().setDirection(self.layout().RightToLeft)
else:
self.setLayout(QVBoxLayout())
self._jobs.setAlignment(Qt.AlignHCenter|Qt.AlignBottom)
self.layout().addWidget(self.pi)
self.layout().addWidget(self._jobs)
if not horizontal:
self.layout().setAlignment(self._jobs, Qt.AlignHCenter)
self._jobs.setMargin(0)
self.layout().setMargin(0)
self._jobs.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
self.setCursor(Qt.PointingHandCursor)
b = _('Click to see list of jobs')
self.setToolTip(b + u' (%s)'%self.shortcut)
self.action_toggle = QAction(b, parent)
parent.addAction(self.action_toggle)
self.action_toggle.setShortcut(self.shortcut)
self.action_toggle.triggered.connect(self.toggle)
示例3: __init__
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))
示例4: PluginConfig
class PluginConfig(QWidget): # {{{
finished = pyqtSignal()
def __init__(self, plugin, parent):
QWidget.__init__(self, parent)
self.plugin = plugin
self.l = l = QVBoxLayout()
self.setLayout(l)
self.c = c = QLabel(_('<b>Configure %(name)s</b><br>%(desc)s') % dict(
name=plugin.name, desc=plugin.description))
c.setAlignment(Qt.AlignHCenter)
l.addWidget(c)
self.config_widget = plugin.config_widget()
self.l.addWidget(self.config_widget)
self.bb = QDialogButtonBox(
QDialogButtonBox.Save|QDialogButtonBox.Cancel,
parent=self)
self.bb.accepted.connect(self.finished)
self.bb.rejected.connect(self.finished)
self.bb.accepted.connect(self.commit)
l.addWidget(self.bb)
self.f = QFrame(self)
self.f.setFrameShape(QFrame.HLine)
l.addWidget(self.f)
def commit(self):
self.plugin.save_settings(self.config_widget)
示例5: timerEvent
def timerEvent(self, event):
if event.timerId() == self.timer.timerId():
if self.isWaitingAfterLine:
self.isWaitingAfterLine = False
self.newPiece()
else:
self.oneLineDown()
else:
QFrame.timerEvent(self, event)
示例6: show
def show(self):
if self.controller:
self.controller.setSponsor()
if self.typ == "QDialog":
QDialog.show(self)
elif self.typ == "QTextEdit":
QTextEdit.show(self)
elif self.typ == "QFrame":
QFrame.show(self)
else:
print "don't know about self.typ == %r" % (self.typ,)
示例7: eventFilter
def eventFilter(self, object, event):
# Update the line numbers for all events on the text edit and the viewport.
# This is easier than connecting all necessary singals.
if object in (self.edit, self.edit.viewport()):
self.number_bar.update()
return False
return QFrame.eventFilter(object, event)
示例8: __init__
def __init__(self, *args):
QFrame.__init__(self, *args)
self.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
self.edit = self.PlainTextEdit()
self.number_bar = self.NumberBar(self.edit)
hbox = QHBoxLayout(self)
hbox.setSpacing(0)
hbox.setMargin(0)
hbox.addWidget(self.number_bar)
hbox.addWidget(self.edit)
self.edit.blockCountChanged.connect(self.number_bar.adjustWidth)
self.edit.updateRequest.connect(self.number_bar.updateContents)
示例9: __init__
def __init__(self, name, plugins, gui_name, parent=None):
QWidget.__init__(self, parent)
self._layout = QVBoxLayout()
self.setLayout(self._layout)
self.label = QLabel(gui_name)
self.sep = QFrame(self)
self.bf = QFont()
self.bf.setBold(True)
self.label.setFont(self.bf)
self.sep.setFrameShape(QFrame.HLine)
self._layout.addWidget(self.label)
self._layout.addWidget(self.sep)
self.plugins = plugins
self.bar = QToolBar(self)
self.bar.setStyleSheet(
'QToolBar { border: none; background: none }')
self.bar.setIconSize(QSize(32, 32))
self.bar.setMovable(False)
self.bar.setFloatable(False)
self.bar.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
self._layout.addWidget(self.bar)
self.actions = []
for p in plugins:
target = partial(self.triggered, p)
ac = self.bar.addAction(QIcon(p.icon), p.gui_name, target)
ac.setToolTip(textwrap.fill(p.description))
ac.setWhatsThis(textwrap.fill(p.description))
ac.setStatusTip(p.description)
self.actions.append(ac)
w = self.bar.widgetForAction(ac)
w.setCursor(Qt.PointingHandCursor)
w.setAutoRaise(True)
w.setMinimumWidth(100)
示例10: __init__
def __init__(self, parent=None):
QFrame.__init__(self, parent)
self.setFocusPolicy(Qt.StrongFocus)
self.setAutoFillBackground(True)
self.capture = 0
self.setFrameShape(self.StyledPanel)
self.setFrameShadow(self.Raised)
self._layout = l = QGridLayout(self)
self.setLayout(l)
self.header = QLabel('')
l.addWidget(self.header, 0, 0, 1, 2)
self.use_default = QRadioButton('')
self.use_custom = QRadioButton(_('Custom'))
l.addWidget(self.use_default, 1, 0, 1, 3)
l.addWidget(self.use_custom, 2, 0, 1, 3)
self.use_custom.toggled.connect(self.custom_toggled)
off = 2
for which in (1, 2):
text = _('&Shortcut:') if which == 1 else _('&Alternate shortcut:')
la = QLabel(text)
la.setStyleSheet('QLabel { margin-left: 1.5em }')
l.addWidget(la, off+which, 0, 1, 3)
setattr(self, 'label%d'%which, la)
button = QPushButton(_('None'), self)
button.clicked.connect(partial(self.capture_clicked, which=which))
button.keyPressEvent = partial(self.key_press_event, which=which)
setattr(self, 'button%d'%which, button)
clear = QToolButton(self)
clear.setIcon(QIcon(I('clear_left.png')))
clear.clicked.connect(partial(self.clear_clicked, which=which))
setattr(self, 'clear%d'%which, clear)
l.addWidget(button, off+which, 1, 1, 1)
l.addWidget(clear, off+which, 2, 1, 1)
la.setBuddy(button)
self.done_button = doneb = QPushButton(_('Done'), self)
l.addWidget(doneb, 0, 2, 1, 1)
doneb.clicked.connect(lambda : self.editing_done.emit(self))
l.setColumnStretch(0, 100)
self.custom_toggled(False)
示例11: _createHeader
def _createHeader(self, iconPath, title):
"""
Creates the Property Manager header, which contains an icon
(a QLabel with a pixmap) and white text (a QLabel with text).
@param iconPath: The relative path for the icon (PNG image) that
appears in the header.
@type iconPath: str
@param title: The title that appears in the header.
@type title: str
"""
# Heading frame (dark gray), which contains
# a pixmap and (white) heading text.
self.headerFrame = QFrame(self)
self.headerFrame.setFrameShape(QFrame.NoFrame)
self.headerFrame.setFrameShadow(QFrame.Plain)
self.headerFrame.setPalette(QPalette(pmHeaderFrameColor))
self.headerFrame.setAutoFillBackground(True)
# HBox layout for heading frame, containing the pixmap
# and label (title).
HeaderFrameHLayout = QHBoxLayout(self.headerFrame)
# 2 pixels around edges --
HeaderFrameHLayout.setMargin(PM_HEADER_FRAME_MARGIN)
# 5 pixel between pixmap and label. --
HeaderFrameHLayout.setSpacing(PM_HEADER_FRAME_SPACING)
# PropMgr icon. Set image by calling setHeaderIcon().
self.headerIcon = QLabel(self.headerFrame)
self.headerIcon.setSizePolicy(
QSizePolicy(QSizePolicy.Policy(QSizePolicy.Fixed),
QSizePolicy.Policy(QSizePolicy.Fixed)))
self.headerIcon.setScaledContents(True)
HeaderFrameHLayout.addWidget(self.headerIcon)
# PropMgr header title text (a QLabel).
self.headerTitle = QLabel(self.headerFrame)
headerTitlePalette = self._getHeaderTitlePalette()
self.headerTitle.setPalette(headerTitlePalette)
self.headerTitle.setAlignment(PM_LABEL_LEFT_ALIGNMENT)
# Assign header title font.
self.headerTitle.setFont(self._getHeaderFont())
HeaderFrameHLayout.addWidget(self.headerTitle)
self.vBoxLayout.addWidget(self.headerFrame)
# Set header icon and title text.
self.setHeaderIcon(iconPath)
self.setHeaderTitle(title)
示例12: __init__
def __init__(self, *args):
QFrame.__init__(self, *args)
self.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
self.edit = QTextEdit()
self.edit.setFrameStyle(QFrame.NoFrame)
self.edit.setAcceptRichText(False)
self.number_bar = NumberBar()
self.number_bar.setTextEdit(self.edit)
hbox = QHBoxLayout(self)
hbox.setSpacing(0)
hbox.setMargin(0)
hbox.addWidget(self.number_bar)
hbox.addWidget(self.edit)
self.edit.installEventFilter(self)
self.edit.viewport().installEventFilter(self)
示例13: __init__
def __init__(self, main, interpreterLocals, ventana_interprete, *args):
QFrame.__init__(self, *args)
self.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
self.editor = WidgetEditor(self, interpreterLocals, ventana_interprete)
self.editor.setFrameStyle(QFrame.NoFrame)
self.editor.setAcceptRichText(False)
self.number_bar = self.NumberBar()
self.number_bar.setTextEdit(self.editor)
hbox = QHBoxLayout(self)
hbox.setSpacing(0)
hbox.setMargin(0)
hbox.addWidget(self.number_bar)
hbox.addWidget(self.editor)
self.editor.installEventFilter(self)
self.editor.viewport().installEventFilter(self)
示例14: __init__
def __init__(self, parent, label, extra_widgets=[], style=QFrame.HLine + QFrame.Raised, offset=16):
QWidget.__init__(self, parent)
lo = QHBoxLayout(self)
lo.setContentsMargins(0, 0, 0, 0)
lo.setSpacing(4)
if offset:
frame = QFrame(self)
frame.setFrameStyle(style)
frame.setMinimumWidth(offset)
lo.addWidget(frame, 0)
lo.addWidget(QLabel(label, self), 0)
frame = QFrame(self)
frame.setFrameStyle(style)
lo.addWidget(frame, 1)
for w in extra_widgets:
lo.addWidget(w, 0)
示例15: _createSponsorButton
def _createSponsorButton(self):
"""
Creates the Property Manager sponsor button, which contains
a QPushButton inside of a QGridLayout inside of a QFrame.
The sponsor logo image is not loaded here.
"""
# Sponsor button (inside a frame)
self.sponsor_frame = QFrame(self)
self.sponsor_frame.setFrameShape(QFrame.NoFrame)
self.sponsor_frame.setFrameShadow(QFrame.Plain)
SponsorFrameGrid = QGridLayout(self.sponsor_frame)
SponsorFrameGrid.setMargin(PM_SPONSOR_FRAME_MARGIN)
SponsorFrameGrid.setSpacing(PM_SPONSOR_FRAME_SPACING) # Has no effect.
self.sponsor_btn = QPushButton(self.sponsor_frame)
self.sponsor_btn.setAutoDefault(False)
self.sponsor_btn.setFlat(True)
self.connect(self.sponsor_btn,
SIGNAL("clicked()"),
self.open_sponsor_homepage)
SponsorFrameGrid.addWidget(self.sponsor_btn, 0, 0, 1, 1)
self.vBoxLayout.addWidget(self.sponsor_frame)
button_whatsthis_widget = self.sponsor_btn
#bruce 070615 bugfix -- put tooltip & whatsthis on self.sponsor_btn,
# not self.
# [self.sponsor_frame might be another possible place to put them.]
button_whatsthis_widget.setWhatsThis("""<b>Sponsor Button</b>
<p>When clicked, this sponsor logo will display a short
description about a NanoEngineer-1 sponsor. This can
be an official sponsor or credit given to a contributor
that has helped code part or all of this command.
A link is provided in the description to learn more
about this sponsor.</p>""")
button_whatsthis_widget.setToolTip("NanoEngineer-1 Sponsor Button")
return