本文整理汇总了Python中PyQt4.Qt.QFrame.setFrameShape方法的典型用法代码示例。如果您正苦于以下问题:Python QFrame.setFrameShape方法的具体用法?Python QFrame.setFrameShape怎么用?Python QFrame.setFrameShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QFrame
的用法示例。
在下文中一共展示了QFrame.setFrameShape方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PluginConfig
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setFrameShape [as 别名]
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)
示例2: Category
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setFrameShape [as 别名]
class Category(QWidget): # {{{
plugin_activated = pyqtSignal(object)
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)
def triggered(self, plugin, *args):
self.plugin_activated.emit(plugin)
示例3: __init__
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setFrameShape [as 别名]
class parameter_dialog_or_frame:
"""
use as a pre-mixin before QDialog or QFrame
"""
####@@@@
def __init__(self, parent = None, desc = None, name = None, modal = 0, fl = 0, env = None, type = "QDialog"):
if env is None:
import foundation.env as env # this is a little weird... probably it'll be ok, and logically it seems correct.
self.desc = desc
self.typ = type
if type == "QDialog":
QDialog.__init__(self,parent,name,modal,fl)
elif type == "QTextEdit":
QTextEdit.__init__(self, parent, name)
elif type == "QFrame":
QFrame.__init__(self,parent,name)
else:
print "don't know about type == %r" % (type,)
self.image1 = QPixmap()
self.image1.loadFromData(image1_data,"PNG") # should be: title_icon ####
self.image3 = QPixmap()
self.image3.loadFromData(image3_data,"PNG")
self.image4 = QPixmap()
self.image4.loadFromData(image4_data,"PNG")
self.image5 = QPixmap()
self.image5.loadFromData(image5_data,"PNG")
self.image6 = QPixmap()
self.image6.loadFromData(image6_data,"PNG")
self.image7 = QPixmap()
self.image7.loadFromData(image7_data,"PNG")
self.image0 = QPixmap(image0_data) # should be: border_icon ####
self.image2 = QPixmap(image2_data) # should be: sponsor_pixmap ####
try:
####@@@@
title_icon_name = self.desc.options.get('title_icon')
border_icon_name = self.desc.options.get('border_icon')
if title_icon_name:
self.image1 = imagename_to_pixmap(title_icon_name) ###@@@ pass icon_path
###@@@ import imagename_to_pixmap or use env function
# or let that func itself be an arg, or have an env arg for it
###e rename it icon_name_to_pixmap, or find_icon? (the latter only if it's ok if it returns an iconset)
###e use iconset instead?
if border_icon_name:
self.image0 = imagename_to_pixmap(border_icon_name)
except:
print_compact_traceback("bug in icon-setting code, using fallback icons: ")
pass
if not name:
self.setName("parameter_dialog_or_frame") ###
###k guess this will need: if type == 'QDialog'
self.setIcon(self.image0) # should be: border_icon ####
nanotube_dialogLayout = QVBoxLayout(self,0,0,"nanotube_dialogLayout")
self.heading_frame = QFrame(self,"heading_frame")
self.heading_frame.setPaletteBackgroundColor(QColor(122,122,122))
self.heading_frame.setFrameShape(QFrame.NoFrame)
self.heading_frame.setFrameShadow(QFrame.Plain)
heading_frameLayout = QHBoxLayout(self.heading_frame,0,3,"heading_frameLayout")
self.heading_pixmap = QLabel(self.heading_frame,"heading_pixmap")
self.heading_pixmap.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.heading_pixmap.sizePolicy().hasHeightForWidth()))
self.heading_pixmap.setPixmap(self.image1) # should be: title_icon ####
self.heading_pixmap.setScaledContents(1)
heading_frameLayout.addWidget(self.heading_pixmap)
self.heading_label = QLabel(self.heading_frame,"heading_label")
self.heading_label.setPaletteForegroundColor(QColor(255,255,255))
heading_label_font = QFont(self.heading_label.font())
heading_label_font.setPointSize(12)
heading_label_font.setBold(1)
self.heading_label.setFont(heading_label_font)
heading_frameLayout.addWidget(self.heading_label)
nanotube_dialogLayout.addWidget(self.heading_frame)
self.body_frame = QFrame(self,"body_frame")
self.body_frame.setFrameShape(QFrame.StyledPanel)
self.body_frame.setFrameShadow(QFrame.Raised)
body_frameLayout = QVBoxLayout(self.body_frame,3,3,"body_frameLayout")
self.sponsor_frame = QFrame(self.body_frame,"sponsor_frame")
self.sponsor_frame.setPaletteBackgroundColor(QColor(255,255,255))
self.sponsor_frame.setFrameShape(QFrame.StyledPanel)
self.sponsor_frame.setFrameShadow(QFrame.Raised)
sponsor_frameLayout = QHBoxLayout(self.sponsor_frame,0,0,"sponsor_frameLayout")
self.sponsor_btn = QPushButton(self.sponsor_frame,"sponsor_btn")
self.sponsor_btn.setAutoDefault(0) #bruce 060703 bugfix
self.sponsor_btn.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Preferred,0,0,self.sponsor_btn.sizePolicy().hasHeightForWidth()))
self.sponsor_btn.setPaletteBackgroundColor(QColor(255,255,255))
self.sponsor_btn.setPixmap(self.image2) # should be: sponsor_pixmap #### [also we'll need to support >1 sponsor]
self.sponsor_btn.setFlat(1)
sponsor_frameLayout.addWidget(self.sponsor_btn)
body_frameLayout.addWidget(self.sponsor_frame)
#.........这里部分代码省略.........
示例4: TweakBook
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setFrameShape [as 别名]
class TweakBook(QDialog):
def __init__(self, parent, book_id, fmts, db):
QDialog.__init__(self, parent)
self.book_id, self.fmts, self.db_ref = book_id, fmts, weakref.ref(db)
self._exploded = None
self._cleanup_dirs = []
self._cleanup_files = []
self.setup_ui()
self.setWindowTitle(_('Tweak Book') + ' - ' + db.title(book_id,
index_is_id=True))
button = self.fmt_choice_buttons[0]
button_map = {unicode(x.text()):x for x in self.fmt_choice_buttons}
of = prefs['output_format'].upper()
df = tweaks.get('default_tweak_format', None)
lf = gprefs.get('last_tweak_format', None)
if df and df.lower() == 'remember' and lf in button_map:
button = button_map[lf]
elif df and df.upper() in button_map:
button = button_map[df.upper()]
elif of in button_map:
button = button_map[of]
button.setChecked(True)
self.init_state()
for button in self.fmt_choice_buttons:
button.toggled.connect(self.init_state)
def init_state(self, *args):
self._exploded = None
self.preview_button.setEnabled(False)
self.rebuild_button.setEnabled(False)
self.explode_button.setEnabled(True)
def setup_ui(self): # {{{
self._g = g = QHBoxLayout(self)
self.setLayout(g)
self._l = l = QVBoxLayout()
g.addLayout(l)
fmts = sorted(x.upper() for x in self.fmts)
self.fmt_choice_box = QGroupBox(_('Choose the format to tweak:'), self)
self._fl = fl = QHBoxLayout()
self.fmt_choice_box.setLayout(self._fl)
self.fmt_choice_buttons = [QRadioButton(y, self) for y in fmts]
for x in self.fmt_choice_buttons:
fl.addWidget(x, stretch=10 if x is self.fmt_choice_buttons[-1] else
0)
l.addWidget(self.fmt_choice_box)
self.fmt_choice_box.setVisible(len(fmts) > 1)
self.help_label = QLabel(_('''\
<h2>About Tweak Book</h2>
<p>Tweak Book allows you to fine tune the appearance of an ebook by
making small changes to its internals. In order to use Tweak Book,
you need to know a little bit about HTML and CSS, technologies that
are used in ebooks. Follow the steps:</p>
<br>
<ol>
<li>Click "Explode Book": This will "explode" the book into its
individual internal components.<br></li>
<li>Right click on any individual file and select "Open with..." to
edit it in your favorite text editor.<br></li>
<li>When you are done Tweaking: <b>close the file browser window
and the editor windows you used to make your tweaks</b>. Then click
the "Rebuild Book" button, to update the book in your calibre
library.</li>
</ol>'''))
self.help_label.setWordWrap(True)
self._fr = QFrame()
self._fr.setFrameShape(QFrame.VLine)
g.addWidget(self._fr)
g.addWidget(self.help_label)
self._b = b = QGridLayout()
left, top, right, bottom = b.getContentsMargins()
top += top
b.setContentsMargins(left, top, right, bottom)
l.addLayout(b, stretch=10)
self.explode_button = QPushButton(QIcon(I('wizard.png')), _('&Explode Book'))
self.preview_button = QPushButton(QIcon(I('view.png')), _('&Preview Book'))
self.cancel_button = QPushButton(QIcon(I('window-close.png')), _('&Cancel'))
self.rebuild_button = QPushButton(QIcon(I('exec.png')), _('&Rebuild Book'))
self.explode_button.setToolTip(
_('Explode the book to edit its components'))
self.preview_button.setToolTip(
_('Preview the result of your tweaks'))
self.cancel_button.setToolTip(
_('Abort without saving any changes'))
self.rebuild_button.setToolTip(
_('Save your changes and update the book in the calibre library'))
a = b.addWidget
a(self.explode_button, 0, 0, 1, 1)
a(self.preview_button, 0, 1, 1, 1)
a(self.cancel_button, 1, 0, 1, 1)
#.........这里部分代码省略.........
示例5: ConfigWidget
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setFrameShape [as 别名]
class ConfigWidget(QWidget, Logger):
'''
Config dialog for Marvin Manager
'''
WIZARD_PROFILES = {
'Annotations': {
'label': 'mm_annotations',
'datatype': 'comments',
'display': {},
'is_multiple': False
},
'Collections': {
'label': 'mm_collections',
'datatype': 'text',
'display': {u'is_names': False},
'is_multiple': True
},
'Last read': {
'label': 'mm_date_read',
'datatype': 'datetime',
'display': {},
'is_multiple': False
},
'Locked': {
'label': 'mm_locked',
'datatype': 'bool',
'display': {},
'is_multiple': False
},
'Progress': {
'label': 'mm_progress',
'datatype': 'float',
'display': {u'number_format': u'{0:.0f}%'},
'is_multiple': False
},
'Read': {
'label': 'mm_read',
'datatype': 'bool',
'display': {},
'is_multiple': False
},
'Reading list': {
'label': 'mm_reading_list',
'datatype': 'bool',
'display': {},
'is_multiple': False
},
'Word count': {
'label': 'mm_word_count',
'datatype': 'int',
'display': {u'number_format': u'{0:n}'},
'is_multiple': False
}
}
def __init__(self, plugin_action):
QWidget.__init__(self)
self.parent = plugin_action
self.gui = get_gui()
self.icon = plugin_action.icon
self.opts = plugin_action.opts
self.prefs = plugin_prefs
self.resources_path = plugin_action.resources_path
self.verbose = plugin_action.verbose
self.restart_required = False
self._log_location()
self.l = QGridLayout()
self.setLayout(self.l)
self.column1_layout = QVBoxLayout()
self.l.addLayout(self.column1_layout, 0, 0)
self.column2_layout = QVBoxLayout()
self.l.addLayout(self.column2_layout, 0, 1)
# ----------------------------- Column 1 -----------------------------
# ~~~~~~~~ Create the Custom fields options group box ~~~~~~~~
self.cfg_custom_fields_gb = QGroupBox(self)
self.cfg_custom_fields_gb.setTitle('Custom column assignments')
self.column1_layout.addWidget(self.cfg_custom_fields_gb)
self.cfg_custom_fields_qgl = QGridLayout(self.cfg_custom_fields_gb)
current_row = 0
# ++++++++ Labels + HLine ++++++++
self.marvin_source_label = QLabel("Marvin source")
self.cfg_custom_fields_qgl.addWidget(self.marvin_source_label, current_row, 0)
self.calibre_destination_label = QLabel("calibre destination")
self.cfg_custom_fields_qgl.addWidget(self.calibre_destination_label, current_row, 1)
current_row += 1
self.sd_hl = QFrame(self.cfg_custom_fields_gb)
self.sd_hl.setFrameShape(QFrame.HLine)
self.sd_hl.setFrameShadow(QFrame.Raised)
self.cfg_custom_fields_qgl.addWidget(self.sd_hl, current_row, 0, 1, 3)
current_row += 1
# ++++++++ Annotations ++++++++
#.........这里部分代码省略.........
示例6: PM_ColorChooser
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setFrameShape [as 别名]
#.........这里部分代码省略.........
@type labelColumn: int
@param color: initial color. White is the default.
@type color: tuple of 3 floats (r, g, b)
@param setAsDefault: if True, will restore L{color} when the
"Restore Defaults" button is clicked.
@type setAsDefault: boolean
@param spanWidth: if True, the widget and its label will span the width
of the group box. Its label will appear directly above
the widget (unless the label is empty) and is left
justified.
@type spanWidth: boolean
@see: U{B{QColorDialog}<http://doc.trolltech.com/4/qcolordialog.html>}
"""
QWidget.__init__(self)
self.parentWidget = parentWidget
self.label = label
self.labelColumn = labelColumn
self.color = color
self.setAsDefault = setAsDefault
self.spanWidth = spanWidth
if label: # Create this widget's QLabel.
self.labelWidget = QLabel()
self.labelWidget.setText(label)
# Create the color frame (color swath) and "..." button.
self.colorFrame = QFrame()
self.colorFrame.setFrameShape(QFrame.Box)
self.colorFrame.setFrameShadow(QFrame.Plain)
# Set browse button text and make signal-slot connection.
self.chooseButton = QToolButton()
self.chooseButton.setText("...")
self.connect(self.chooseButton, SIGNAL("clicked()"), self.openColorChooserDialog)
# Add a horizontal spacer to keep the colorFrame and "..." squeezed
# together, even when the PM width changes.
self.hSpacer = QSpacerItem(10, 10,
QSizePolicy.MinimumExpanding,
QSizePolicy.Fixed)
# Create vertical box layout.
self.hBoxLayout = QHBoxLayout(self)
self.hBoxLayout.setMargin(0)
self.hBoxLayout.setSpacing(2)
self.hBoxLayout.insertWidget(-1, self.colorFrame)
self.hBoxLayout.insertWidget(-1, self.chooseButton)
# Set this to False to make the colorFrame an expandable rectangle.
COLORFRAME_IS_SQUARE = True
if COLORFRAME_IS_SQUARE:
squareSize = 20
self.colorFrame.setMinimumSize(QSize(squareSize, squareSize))
self.colorFrame.setMaximumSize(QSize(squareSize, squareSize))
self.hBoxLayout.addItem(self.hSpacer)
self.setColor(color, default = setAsDefault)
parentWidget.addPmWidget(self)
return
示例7: RuleEditor
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setFrameShape [as 别名]
class RuleEditor(QDialog): # {{{
def __init__(self, fm, parent=None):
QDialog.__init__(self, parent)
self.fm = fm
self.setWindowIcon(QIcon(I('format-fill-color.png')))
self.setWindowTitle(_('Create/edit a column coloring rule'))
self.l = l = QGridLayout(self)
self.setLayout(l)
self.l1 = l1 = QLabel(_('Create a coloring rule by'
' filling in the boxes below'))
l.addWidget(l1, 0, 0, 1, 5)
self.f1 = QFrame(self)
self.f1.setFrameShape(QFrame.HLine)
l.addWidget(self.f1, 1, 0, 1, 5)
self.l2 = l2 = QLabel(_('Set the color of the column:'))
l.addWidget(l2, 2, 0)
self.column_box = QComboBox(self)
l.addWidget(self.column_box, 2, 1)
self.l3 = l3 = QLabel(_('to'))
l.addWidget(l3, 2, 2)
self.color_box = QComboBox(self)
self.color_label = QLabel('Sample text Sample text')
self.color_label.setTextFormat(Qt.RichText)
l.addWidget(self.color_box, 2, 3)
l.addWidget(self.color_label, 2, 4)
l.addItem(QSpacerItem(10, 10, QSizePolicy.Expanding), 2, 5)
self.l4 = l4 = QLabel(
_('Only if the following conditions are all satisfied:'))
l.addWidget(l4, 3, 0, 1, 6)
self.scroll_area = sa = QScrollArea(self)
sa.setMinimumHeight(300)
sa.setMinimumWidth(950)
sa.setWidgetResizable(True)
l.addWidget(sa, 4, 0, 1, 6)
self.add_button = b = QPushButton(QIcon(I('plus.png')),
_('Add another condition'))
l.addWidget(b, 5, 0, 1, 6)
b.clicked.connect(self.add_blank_condition)
self.l5 = l5 = QLabel(_('You can disable a condition by'
' blanking all of its boxes'))
l.addWidget(l5, 6, 0, 1, 6)
self.bb = bb = QDialogButtonBox(
QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
bb.accepted.connect(self.accept)
bb.rejected.connect(self.reject)
l.addWidget(bb, 7, 0, 1, 6)
self.conditions_widget = QWidget(self)
sa.setWidget(self.conditions_widget)
self.conditions_widget.setLayout(QVBoxLayout())
self.conditions_widget.layout().setAlignment(Qt.AlignTop)
self.conditions = []
for b in (self.column_box, self.color_box):
b.setSizeAdjustPolicy(b.AdjustToMinimumContentsLengthWithIcon)
b.setMinimumContentsLength(15)
for key in sorted(
displayable_columns(fm),
key=sort_key):
name = fm[key]['name']
if name:
self.column_box.addItem(key, key)
self.column_box.setCurrentIndex(0)
self.color_box.addItems(QColor.colorNames())
self.color_box.setCurrentIndex(0)
self.update_color_label()
self.color_box.currentIndexChanged.connect(self.update_color_label)
self.resize(self.sizeHint())
def update_color_label(self):
pal = QApplication.palette()
bg1 = unicode(pal.color(pal.Base).name())
bg2 = unicode(pal.color(pal.AlternateBase).name())
c = unicode(self.color_box.currentText())
self.color_label.setText('''
<span style="color: {c}; background-color: {bg1}"> {st} </span>
<span style="color: {c}; background-color: {bg2}"> {st} </span>
'''.format(c=c, bg1=bg1, bg2=bg2, st=_('Sample Text')))
def add_blank_condition(self):
c = ConditionEditor(self.fm, parent=self.conditions_widget)
self.conditions.append(c)
#.........这里部分代码省略.........
示例8: RuleEditor
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setFrameShape [as 别名]
class RuleEditor(QDialog): # {{{
def __init__(self, fm, pref_name, parent=None):
QDialog.__init__(self, parent)
self.fm = fm
if pref_name == 'column_color_rules':
self.rule_kind = 'color'
rule_text = _('coloring')
else:
self.rule_kind = 'icon'
rule_text = _('icon')
self.setWindowIcon(QIcon(I('format-fill-color.png')))
self.setWindowTitle(_('Create/edit a column {0} rule').format(rule_text))
self.l = l = QGridLayout(self)
self.setLayout(l)
self.l1 = l1 = QLabel(_('Create a column {0} rule by'
' filling in the boxes below'.format(rule_text)))
l.addWidget(l1, 0, 0, 1, 8)
self.f1 = QFrame(self)
self.f1.setFrameShape(QFrame.HLine)
l.addWidget(self.f1, 1, 0, 1, 8)
self.l2 = l2 = QLabel(_('Set the'))
l.addWidget(l2, 2, 0)
if self.rule_kind == 'color':
l.addWidget(QLabel(_('color')))
else:
self.kind_box = QComboBox(self)
for tt, t in icon_rule_kinds:
self.kind_box.addItem(tt, t)
l.addWidget(self.kind_box, 2, 1)
self.l3 = l3 = QLabel(_('of the column:'))
l.addWidget(l3, 2, 2)
self.column_box = QComboBox(self)
l.addWidget(self.column_box, 2, 3)
self.l4 = l4 = QLabel(_('to'))
l.addWidget(l4, 2, 4)
if self.rule_kind == 'color':
self.color_box = QComboBox(self)
self.color_label = QLabel('Sample text Sample text')
self.color_label.setTextFormat(Qt.RichText)
l.addWidget(self.color_box, 2, 5)
l.addWidget(self.color_label, 2, 6)
l.addItem(QSpacerItem(10, 10, QSizePolicy.Expanding), 2, 7)
else:
self.filename_box = QComboBox()
self.filename_box.setInsertPolicy(self.filename_box.InsertAlphabetically)
d = os.path.join(config_dir, 'cc_icons')
self.icon_file_names = []
if os.path.exists(d):
for icon_file in os.listdir(d):
icon_file = lower(icon_file)
if os.path.exists(os.path.join(d, icon_file)):
if icon_file.endswith('.png'):
self.icon_file_names.append(icon_file)
self.icon_file_names.sort(key=sort_key)
self.update_filename_box()
l.addWidget(self.filename_box, 2, 5)
self.filename_button = QPushButton(QIcon(I('document_open.png')),
_('&Add icon'))
l.addWidget(self.filename_button, 2, 6)
l.addWidget(QLabel(_('Icons should be square or landscape')), 2, 7)
l.setColumnStretch(7, 10)
self.l5 = l5 = QLabel(
_('Only if the following conditions are all satisfied:'))
l.addWidget(l5, 3, 0, 1, 7)
self.scroll_area = sa = QScrollArea(self)
sa.setMinimumHeight(300)
sa.setMinimumWidth(950)
sa.setWidgetResizable(True)
l.addWidget(sa, 4, 0, 1, 8)
self.add_button = b = QPushButton(QIcon(I('plus.png')),
_('Add another condition'))
l.addWidget(b, 5, 0, 1, 8)
b.clicked.connect(self.add_blank_condition)
self.l6 = l6 = QLabel(_('You can disable a condition by'
' blanking all of its boxes'))
l.addWidget(l6, 6, 0, 1, 8)
self.bb = bb = QDialogButtonBox(
QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
bb.accepted.connect(self.accept)
bb.rejected.connect(self.reject)
l.addWidget(bb, 7, 0, 1, 8)
#.........这里部分代码省略.........
示例9: RuleEditor
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setFrameShape [as 别名]
class RuleEditor(QDialog): # {{{
@property
def doing_multiple(self):
return hasattr(self, 'multiple_icon_cb') and self.multiple_icon_cb.isChecked()
def __init__(self, fm, pref_name, parent=None):
QDialog.__init__(self, parent)
self.fm = fm
if pref_name == 'column_color_rules':
self.rule_kind = 'color'
rule_text = _('column coloring')
elif pref_name == 'column_icon_rules':
self.rule_kind = 'icon'
rule_text = _('column icon')
elif pref_name == 'cover_grid_icon_rules':
self.rule_kind = 'emblem'
rule_text = _('cover grid emblem')
self.setWindowIcon(QIcon(I('format-fill-color.png')))
self.setWindowTitle(_('Create/edit a {0} rule').format(rule_text))
self.l = l = QGridLayout(self)
self.setLayout(l)
self.l1 = l1 = QLabel(_('Create a {0} rule by'
' filling in the boxes below'.format(rule_text)))
l.addWidget(l1, 0, 0, 1, 8)
self.f1 = QFrame(self)
self.f1.setFrameShape(QFrame.HLine)
l.addWidget(self.f1, 1, 0, 1, 8)
self.l2 = l2 = QLabel(_('Add the emblem:') if self.rule_kind == 'emblem' else _('Set the'))
l.addWidget(l2, 2, 0)
if self.rule_kind == 'color':
l.addWidget(QLabel(_('color')))
elif self.rule_kind == 'icon':
self.kind_box = QComboBox(self)
for tt, t in icon_rule_kinds:
self.kind_box.addItem(tt, t)
l.addWidget(self.kind_box, 2, 1)
self.kind_box.setToolTip(textwrap.fill(_(
'If you choose composed icons and multiple rules match, then all the'
' matching icons will be combined, otherwise the icon from the'
' first rule to match will be used.')))
else:
pass
self.l3 = l3 = QLabel(_('of the column:'))
l.addWidget(l3, 2, 2)
self.column_box = QComboBox(self)
l.addWidget(self.column_box, 2, 3)
self.l4 = l4 = QLabel(_('to'))
l.addWidget(l4, 2, 4)
if self.rule_kind == 'emblem':
l3.setVisible(False), self.column_box.setVisible(False), l4.setVisible(False)
def create_filename_box():
self.filename_box = f = QComboBox()
f.setMinimumContentsLength(20), f.setSizeAdjustPolicy(f.AdjustToMinimumContentsLengthWithIcon)
self.populate_icon_filenames()
if self.rule_kind == 'color':
self.color_box = ColorButton(parent=self)
self.color_label = QLabel('Sample text Sample text')
self.color_label.setTextFormat(Qt.RichText)
l.addWidget(self.color_box, 2, 5)
l.addWidget(self.color_label, 2, 6)
l.addItem(QSpacerItem(10, 10, QSizePolicy.Expanding), 2, 7)
elif self.rule_kind == 'emblem':
create_filename_box()
self.update_filename_box()
self.filename_button = QPushButton(QIcon(I('document_open.png')),
_('&Add new image'))
l.addWidget(self.filename_box)
l.addWidget(self.filename_button, 2, 6)
l.addWidget(QLabel(_('(Images should be square-ish)')), 2, 7)
l.setColumnStretch(7, 10)
else:
create_filename_box()
vb = QVBoxLayout()
self.multiple_icon_cb = QCheckBox(_('Choose more than one icon'))
vb.addWidget(self.multiple_icon_cb)
self.update_filename_box()
self.multiple_icon_cb.clicked.connect(self.multiple_box_clicked)
vb.addWidget(self.filename_box)
l.addLayout(vb, 2, 5)
self.filename_button = QPushButton(QIcon(I('document_open.png')),
_('&Add icon'))
l.addWidget(self.filename_button, 2, 6)
l.addWidget(QLabel(_('Icons should be square or landscape')), 2, 7)
l.setColumnStretch(7, 10)
#.........这里部分代码省略.........
示例10: PM_Dialog
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setFrameShape [as 别名]
#.........这里部分代码省略.........
Subclasses can override this to update some cosmetic properties
of their associated model objects before closing self
(the Property Manager).
"""
pass
def updateMessage(self, msg = ''):
"""
Updates the message box with an informative message
@param msg: Message to be displayed in the Message groupbox of
the property manager
@type msg: string
"""
self.MessageGroupBox.insertHtmlMessage(msg,
setAsDefault = False,
minLines = 5)
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)
示例11: VLine
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setFrameShape [as 别名]
def VLine(self):
line = QFrame()
line.setFrameStyle(QFrame.VLine)
line.setFrameShape(QFrame.VLine)
line.setFrameShadow(QFrame.Sunken)
return line