本文整理汇总了Python中PyQt4.Qt.QCheckBox.setChecked方法的典型用法代码示例。如果您正苦于以下问题:Python QCheckBox.setChecked方法的具体用法?Python QCheckBox.setChecked怎么用?Python QCheckBox.setChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QCheckBox
的用法示例。
在下文中一共展示了QCheckBox.setChecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_store_checks
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
def setup_store_checks(self):
first_run = self.config.get('first_run', True)
# Add check boxes for each store so the user
# can disable searching specific stores on a
# per search basis.
existing = {}
for n in self.store_checks:
existing[n] = self.store_checks[n].isChecked()
self.store_checks = {}
stores_check_widget = QWidget()
store_list_layout = QGridLayout()
stores_check_widget.setLayout(store_list_layout)
icon = QIcon(I('donate.png'))
for i, x in enumerate(sorted(self.gui.istores.keys(), key=lambda x: x.lower())):
cbox = QCheckBox(x)
cbox.setChecked(existing.get(x, first_run))
store_list_layout.addWidget(cbox, i, 0, 1, 1)
if self.gui.istores[x].base_plugin.affiliate:
iw = QLabel(self)
iw.setToolTip('<p>' + _('Buying from this store supports the calibre developer: %s</p>') % self.gui.istores[x].base_plugin.author + '</p>')
iw.setPixmap(icon.pixmap(16, 16))
store_list_layout.addWidget(iw, i, 1, 1, 1)
self.store_checks[x] = cbox
store_list_layout.setRowStretch(store_list_layout.rowCount(), 10)
self.store_list.setWidget(stores_check_widget)
self.config['first_run'] = False
示例2: UpdateNotification
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
class UpdateNotification(QDialog):
def __init__(self, calibre_version, plugin_updates, parent=None):
QDialog.__init__(self, parent)
self.setAttribute(Qt.WA_QuitOnClose, False)
self.resize(400, 250)
self.l = QGridLayout()
self.setLayout(self.l)
self.logo = QLabel()
self.logo.setMaximumWidth(110)
self.logo.setPixmap(QPixmap(I('lt.png')).scaled(100, 100,
Qt.IgnoreAspectRatio, Qt.SmoothTransformation))
ver = calibre_version
if ver.endswith('.0'):
ver = ver[:-2]
self.label = QLabel(('<p>'+
_('New version <b>%(ver)s</b> of %(app)s is available for download. '
'See the <a href="http://calibre-ebook.com/whats-new'
'">new features</a>.'))%dict(
app=__appname__, ver=ver))
self.label.setOpenExternalLinks(True)
self.label.setWordWrap(True)
self.setWindowTitle(_('Update available!'))
self.setWindowIcon(QIcon(I('lt.png')))
self.l.addWidget(self.logo, 0, 0)
self.l.addWidget(self.label, 0, 1)
self.cb = QCheckBox(
_('Show this notification for future updates'), self)
self.l.addWidget(self.cb, 1, 0, 1, -1)
self.cb.setChecked(config.get('new_version_notification'))
self.cb.stateChanged.connect(self.show_future)
self.bb = QDialogButtonBox(self)
b = self.bb.addButton(_('&Get update'), self.bb.AcceptRole)
b.setDefault(True)
b.setIcon(QIcon(I('arrow-down.png')))
if plugin_updates > 0:
b = self.bb.addButton(_('Update &plugins'), self.bb.ActionRole)
b.setIcon(QIcon(I('plugins/plugin_updater.png')))
b.clicked.connect(self.get_plugins, type=Qt.QueuedConnection)
self.bb.addButton(self.bb.Cancel)
self.l.addWidget(self.bb, 2, 0, 1, -1)
self.bb.accepted.connect(self.accept)
self.bb.rejected.connect(self.reject)
dynamic.set('update to version %s'%calibre_version, False)
def get_plugins(self):
from calibre.gui2.dialogs.plugin_updater import (PluginUpdaterDialog,
FILTER_UPDATE_AVAILABLE)
d = PluginUpdaterDialog(self.parent(),
initial_filter=FILTER_UPDATE_AVAILABLE)
d.exec_()
def show_future(self, *args):
config.set('new_version_notification', bool(self.cb.isChecked()))
def accept(self):
open_url(QUrl(get_download_url()))
QDialog.accept(self)
示例3: do_user_config
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
def do_user_config(self, parent=None):
'''
This method shows a configuration dialog for this plugin. It returns
True if the user clicks OK, False otherwise. The changes are
automatically applied.
'''
from PyQt4.Qt import (QDialog, QDialogButtonBox, QVBoxLayout,
QLabel, Qt, QLineEdit, QCheckBox)
config_dialog = QDialog(parent)
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
v = QVBoxLayout(config_dialog)
def size_dialog():
config_dialog.resize(config_dialog.sizeHint())
button_box.accepted.connect(config_dialog.accept)
button_box.rejected.connect(config_dialog.reject)
config_dialog.setWindowTitle(_('Customize') + ' ' + self.name)
from calibre.customize.ui import (plugin_customization,
customize_plugin)
help_text = self.customization_help(gui=True)
help_text = QLabel(help_text, config_dialog)
help_text.setWordWrap(True)
help_text.setTextInteractionFlags(Qt.LinksAccessibleByMouse
| Qt.LinksAccessibleByKeyboard)
help_text.setOpenExternalLinks(True)
v.addWidget(help_text)
bf = QCheckBox(_('Add linked files in breadth first order'))
bf.setToolTip(_('Normally, when following links in HTML files'
' calibre does it depth first, i.e. if file A links to B and '
' C, but B links to D, the files are added in the order A, B, D, C. '
' With this option, they will instead be added as A, B, C, D'))
sc = plugin_customization(self)
if not sc:
sc = ''
sc = sc.strip()
enc = sc.partition('|')[0]
bfs = sc.partition('|')[-1]
bf.setChecked(bfs == 'bf')
sc = QLineEdit(enc, config_dialog)
v.addWidget(sc)
v.addWidget(bf)
v.addWidget(button_box)
size_dialog()
config_dialog.exec_()
if config_dialog.result() == QDialog.Accepted:
sc = unicode(sc.text()).strip()
if bf.isChecked():
sc += '|bf'
customize_plugin(self, sc)
return config_dialog.result()
示例4: ConfigWidget
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
class ConfigWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
self.l = QGridLayout()
self.setLayout(self.l)
self.newFormatCheckboxLabel = QLabel("Generate new format data (SQLite3)")
self.l.addWidget(self.newFormatCheckboxLabel, 0, 0, 1, 1)
self.newFormatCheckbox = QCheckBox(self)
self.l.addWidget(self.newFormatCheckbox, 0, 1, 1, 1)
self.newFormatCheckbox.setChecked(prefs["newFormat"])
# ARTTBD Maybe should be a native directory picker? Works for now..
self.cacheDirLabel = QLabel("Caching directory (optional, useful if re-running for a given book)")
self.l.addWidget(self.cacheDirLabel, 1, 0, 1, 1)
self.cacheDirEdit = QLineEdit(self)
self.l.addWidget(self.cacheDirEdit, 1, 1, 1, 1)
self.cacheDirEdit.setText(prefs["cacheDir"])
self.autoExpandAliasesLabel = QLabel("Auto-generate aliases from character names")
self.l.addWidget(self.autoExpandAliasesLabel, 2, 0, 1, 1)
self.autoExpandAliasesCheckbox = QCheckBox(self)
self.l.addWidget(self.autoExpandAliasesCheckbox, 2, 1, 1, 1)
self.autoExpandAliasesCheckbox.setChecked(prefs["autoExpandAliases"])
self.logfileLabel = QLabel("Log file (optional)")
self.l.addWidget(self.logfileLabel, 3, 0, 1, 1)
self.logfileEdit = QLineEdit(self)
self.l.addWidget(self.logfileEdit, 3, 1, 1, 1)
self.logfileEdit.setText(prefs["logfile"])
def save_settings(self):
prefs["newFormat"] = self.newFormatCheckbox.isChecked()
prefs["cacheDir"] = unicode(self.cacheDirEdit.text())
prefs["autoExpandAliases"] = self.autoExpandAliasesCheckbox.isChecked()
prefs["logfile"] = unicode(self.logfileEdit.text())
示例5: Choose
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
class Choose(QDialog):
def __init__(self, fmts, parent=None):
QDialog.__init__(self, parent)
self.l = l = QVBoxLayout(self)
self.setLayout(l)
self.setWindowTitle(_('Choose format to edit'))
self.la = la = QLabel(_(
'This book has multiple formats that can be edited. Choose the format you want to edit.'))
l.addWidget(la)
self.rem = QCheckBox(_('Always ask when more than one format is available'))
self.rem.setChecked(True)
l.addWidget(self.rem)
self.bb = bb = QDialogButtonBox(self)
l.addWidget(bb)
bb.accepted.connect(self.accept)
bb.rejected.connect(self.reject)
self.buts = buts = []
for fmt in fmts:
b = bb.addButton(fmt.upper(), bb.AcceptRole)
b.clicked.connect(partial(self.chosen, fmt))
buts.append(b)
self.fmt = None
self.resize(self.sizeHint())
def chosen(self, fmt):
self.fmt = fmt
def accept(self):
from calibre.gui2.tweak_book import tprefs
tprefs['choose_tweak_fmt'] = self.rem.isChecked()
QDialog.accept(self)
示例6: __init__
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
def __init__(self, formats, parent=None):
QDialog.__init__(self, parent)
self.setWindowTitle(_('Choose format to edit'))
self.setWindowIcon(QIcon(I('dialog_question.png')))
l = self.l = QGridLayout()
self.setLayout(l)
la = self.la = QLabel(_('Choose which format you want to edit:'))
formats = sorted(formats)
l.addWidget(la, 0, 0, 1, -1)
self.buttons = []
for i, f in enumerate(formats):
b = QCheckBox('&' + f, self)
l.addWidget(b, 1, i)
self.buttons.append(b)
if i == 0:
b.setChecked(True)
bb = self.bb = QDialogButtonBox(
QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
bb.addButton(_('&All formats'),
bb.ActionRole).clicked.connect(self.do_all)
bb.accepted.connect(self.accept)
bb.rejected.connect(self.reject)
l.addWidget(bb, l.rowCount(), 0, 1, -1)
self.resize(self.sizeHint())
示例7: __init__
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
def __init__(self, parent, rc, imgman):
"""An ImageControlDialog is initialized with a parent widget, a RenderControl object,
and an ImageManager object"""
QDialog.__init__(self, parent)
image = rc.image
self.setWindowTitle("%s: Colour Controls" % image.name)
self.setWindowIcon(pixmaps.colours.icon())
self.setModal(False)
self.image = image
self._rc = rc
self._imgman = imgman
self._currier = PersistentCurrier()
# init internal state
self._prev_range = self._display_range = None, None
self._hist = None
self._geometry = None
# create layouts
lo0 = QVBoxLayout(self)
# lo0.setContentsMargins(0,0,0,0)
# histogram plot
whide = self.makeButton("Hide", self.hide, width=128)
whide.setShortcut(Qt.Key_F9)
lo0.addWidget(Separator(self, "Histogram and ITF", extra_widgets=[whide]))
lo1 = QHBoxLayout()
lo1.setContentsMargins(0, 0, 0, 0)
self._histplot = QwtPlot(self)
self._histplot.setAutoDelete(False)
lo1.addWidget(self._histplot, 1)
lo2 = QHBoxLayout()
lo2.setContentsMargins(0, 0, 0, 0)
lo2.setSpacing(2)
lo0.addLayout(lo2)
lo0.addLayout(lo1)
self._wautozoom = QCheckBox("autozoom", self)
self._wautozoom.setChecked(True)
self._wautozoom.setToolTip("""<P>If checked, then the histrogram plot will zoom in automatically when
you narrow the current intensity range.</P>""")
self._wlogy = QCheckBox("log Y", self)
self._wlogy.setChecked(True)
self._ylogscale = True
self._wlogy.setToolTip(
"""<P>If checked, a log-scale Y axis is used for the histogram plot instead of a linear one.""")
QObject.connect(self._wlogy, SIGNAL("toggled(bool)"), self._setHistLogScale)
self._whistunzoom = self.makeButton("", self._unzoomHistogram, icon=pixmaps.full_range.icon())
self._whistzoomout = self.makeButton("-", self._currier.curry(self._zoomHistogramByFactor, math.sqrt(.1)))
self._whistzoomin = self.makeButton("+", self._currier.curry(self._zoomHistogramByFactor, math.sqrt(10)))
self._whistzoomin.setToolTip("""<P>Click to zoom into the histogram plot by one step. This does not
change the current intensity range.</P>""")
self._whistzoomout.setToolTip("""<P>Click to zoom out of the histogram plot by one step. This does not
change the current intensity range.</P>""")
self._whistunzoom.setToolTip("""<P>Click to reset the histogram plot back to its full extent.
This does not change the current intensity range.</P>""")
self._whistzoom = QwtWheel(self)
self._whistzoom.setOrientation(Qt.Horizontal)
self._whistzoom.setMaximumWidth(80)
self._whistzoom.setRange(10, 0)
self._whistzoom.setStep(0.1)
self._whistzoom.setTickCnt(30)
self._whistzoom.setTracking(False)
QObject.connect(self._whistzoom, SIGNAL("valueChanged(double)"), self._zoomHistogramFinalize)
QObject.connect(self._whistzoom, SIGNAL("sliderMoved(double)"), self._zoomHistogramPreview)
self._whistzoom.setToolTip("""<P>Use this wheel control to zoom in/out of the histogram plot.
This does not change the current intensity range.
Note that the zoom wheel should also respond to your mouse wheel, if you have one.</P>""")
# This works around a stupid bug in QwtSliders -- when using the mousewheel, only sliderMoved() signals are emitted,
# with no final valueChanged(). If we want to do a fast preview of something on sliderMoved(), and a "slow" final
# step on valueChanged(), we're in trouble. So we start a timer on sliderMoved(), and if the timer expires without
# anything else happening, do a valueChanged().
# Here we use a timer to call zoomHistogramFinalize() w/o an argument.
self._whistzoom_timer = QTimer(self)
self._whistzoom_timer.setSingleShot(True)
self._whistzoom_timer.setInterval(500)
QObject.connect(self._whistzoom_timer, SIGNAL("timeout()"), self._zoomHistogramFinalize)
# set same size for all buttons and controls
width = 24
for w in self._whistunzoom, self._whistzoomin, self._whistzoomout:
w.setMinimumSize(width, width)
w.setMaximumSize(width, width)
self._whistzoom.setMinimumSize(80, width)
self._wlab_histpos_text = "(hover here for help)"
self._wlab_histpos = QLabel(self._wlab_histpos_text, self)
self._wlab_histpos.setToolTip("""
<P>The plot shows a histogram of either the full image or its selected subset
(as per the "Data subset" section below).</P>
<P>The current intensity range is indicated by the grey box
in the plot.</P>
<P>Use the left mouse button to change the low intensity limit, and the right
button (on Macs, use Ctrl-click) to change the high limit.</P>
<P>Use Shift with the left mouse button to zoom into an area of the histogram,
or else use the "zoom wheel" control or the plus/minus toolbuttons above the histogram to zoom in or out.
To zoom back out to the full extent of the histogram, click on the rightmost button above the histogram.</P>
""")
lo2.addWidget(self._wlab_histpos, 1)
lo2.addWidget(self._wautozoom)
lo2.addWidget(self._wlogy, 0)
lo2.addWidget(self._whistzoomin, 0)
lo2.addWidget(self._whistzoom, 0)
#.........这里部分代码省略.........
示例8: ImageControlDialog
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
class ImageControlDialog(QDialog):
def __init__(self, parent, rc, imgman):
"""An ImageControlDialog is initialized with a parent widget, a RenderControl object,
and an ImageManager object"""
QDialog.__init__(self, parent)
image = rc.image
self.setWindowTitle("%s: Colour Controls" % image.name)
self.setWindowIcon(pixmaps.colours.icon())
self.setModal(False)
self.image = image
self._rc = rc
self._imgman = imgman
self._currier = PersistentCurrier()
# init internal state
self._prev_range = self._display_range = None, None
self._hist = None
self._geometry = None
# create layouts
lo0 = QVBoxLayout(self)
# lo0.setContentsMargins(0,0,0,0)
# histogram plot
whide = self.makeButton("Hide", self.hide, width=128)
whide.setShortcut(Qt.Key_F9)
lo0.addWidget(Separator(self, "Histogram and ITF", extra_widgets=[whide]))
lo1 = QHBoxLayout()
lo1.setContentsMargins(0, 0, 0, 0)
self._histplot = QwtPlot(self)
self._histplot.setAutoDelete(False)
lo1.addWidget(self._histplot, 1)
lo2 = QHBoxLayout()
lo2.setContentsMargins(0, 0, 0, 0)
lo2.setSpacing(2)
lo0.addLayout(lo2)
lo0.addLayout(lo1)
self._wautozoom = QCheckBox("autozoom", self)
self._wautozoom.setChecked(True)
self._wautozoom.setToolTip("""<P>If checked, then the histrogram plot will zoom in automatically when
you narrow the current intensity range.</P>""")
self._wlogy = QCheckBox("log Y", self)
self._wlogy.setChecked(True)
self._ylogscale = True
self._wlogy.setToolTip(
"""<P>If checked, a log-scale Y axis is used for the histogram plot instead of a linear one.""")
QObject.connect(self._wlogy, SIGNAL("toggled(bool)"), self._setHistLogScale)
self._whistunzoom = self.makeButton("", self._unzoomHistogram, icon=pixmaps.full_range.icon())
self._whistzoomout = self.makeButton("-", self._currier.curry(self._zoomHistogramByFactor, math.sqrt(.1)))
self._whistzoomin = self.makeButton("+", self._currier.curry(self._zoomHistogramByFactor, math.sqrt(10)))
self._whistzoomin.setToolTip("""<P>Click to zoom into the histogram plot by one step. This does not
change the current intensity range.</P>""")
self._whistzoomout.setToolTip("""<P>Click to zoom out of the histogram plot by one step. This does not
change the current intensity range.</P>""")
self._whistunzoom.setToolTip("""<P>Click to reset the histogram plot back to its full extent.
This does not change the current intensity range.</P>""")
self._whistzoom = QwtWheel(self)
self._whistzoom.setOrientation(Qt.Horizontal)
self._whistzoom.setMaximumWidth(80)
self._whistzoom.setRange(10, 0)
self._whistzoom.setStep(0.1)
self._whistzoom.setTickCnt(30)
self._whistzoom.setTracking(False)
QObject.connect(self._whistzoom, SIGNAL("valueChanged(double)"), self._zoomHistogramFinalize)
QObject.connect(self._whistzoom, SIGNAL("sliderMoved(double)"), self._zoomHistogramPreview)
self._whistzoom.setToolTip("""<P>Use this wheel control to zoom in/out of the histogram plot.
This does not change the current intensity range.
Note that the zoom wheel should also respond to your mouse wheel, if you have one.</P>""")
# This works around a stupid bug in QwtSliders -- when using the mousewheel, only sliderMoved() signals are emitted,
# with no final valueChanged(). If we want to do a fast preview of something on sliderMoved(), and a "slow" final
# step on valueChanged(), we're in trouble. So we start a timer on sliderMoved(), and if the timer expires without
# anything else happening, do a valueChanged().
# Here we use a timer to call zoomHistogramFinalize() w/o an argument.
self._whistzoom_timer = QTimer(self)
self._whistzoom_timer.setSingleShot(True)
self._whistzoom_timer.setInterval(500)
QObject.connect(self._whistzoom_timer, SIGNAL("timeout()"), self._zoomHistogramFinalize)
# set same size for all buttons and controls
width = 24
for w in self._whistunzoom, self._whistzoomin, self._whistzoomout:
w.setMinimumSize(width, width)
w.setMaximumSize(width, width)
self._whistzoom.setMinimumSize(80, width)
self._wlab_histpos_text = "(hover here for help)"
self._wlab_histpos = QLabel(self._wlab_histpos_text, self)
self._wlab_histpos.setToolTip("""
<P>The plot shows a histogram of either the full image or its selected subset
(as per the "Data subset" section below).</P>
<P>The current intensity range is indicated by the grey box
in the plot.</P>
<P>Use the left mouse button to change the low intensity limit, and the right
button (on Macs, use Ctrl-click) to change the high limit.</P>
<P>Use Shift with the left mouse button to zoom into an area of the histogram,
or else use the "zoom wheel" control or the plus/minus toolbuttons above the histogram to zoom in or out.
To zoom back out to the full extent of the histogram, click on the rightmost button above the histogram.</P>
""")
lo2.addWidget(self._wlab_histpos, 1)
lo2.addWidget(self._wautozoom)
lo2.addWidget(self._wlogy, 0)
lo2.addWidget(self._whistzoomin, 0)
#.........这里部分代码省略.........
示例9: Report
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
class Report(QDialog): # {{{
def __init__(self, parent):
QDialog.__init__(self, parent)
self.gui = parent
self.setAttribute(Qt.WA_DeleteOnClose, False)
self.setWindowIcon(QIcon(I('polish.png')))
self.reports = []
self.l = l = QGridLayout()
self.setLayout(l)
self.view = v = QTextEdit(self)
v.setReadOnly(True)
l.addWidget(self.view, 0, 0, 1, 2)
self.backup_msg = la = QLabel('')
l.addWidget(la, 1, 0, 1, 2)
la.setVisible(False)
la.setWordWrap(True)
self.ign_msg = _('Ignore remaining %d reports')
self.ign = QCheckBox(self.ign_msg, self)
l.addWidget(self.ign, 2, 0)
bb = self.bb = QDialogButtonBox(QDialogButtonBox.Close)
bb.accepted.connect(self.accept)
bb.rejected.connect(self.reject)
b = self.log_button = bb.addButton(_('View full &log'), bb.ActionRole)
b.clicked.connect(self.view_log)
bb.button(bb.Close).setDefault(True)
l.addWidget(bb, 2, 1)
self.finished.connect(self.show_next, type=Qt.QueuedConnection)
self.resize(QSize(800, 600))
def setup_ign(self):
self.ign.setText(self.ign_msg%len(self.reports))
self.ign.setVisible(bool(self.reports))
self.ign.setChecked(False)
def __call__(self, *args):
self.reports.append(args)
self.setup_ign()
if not self.isVisible():
self.show_next()
def show_report(self, book_title, book_id, fmts, job, report):
from calibre.ebooks.markdown.markdown import markdown
self.current_log = job.details
self.setWindowTitle(_('Polishing of %s')%book_title)
self.view.setText(markdown('# %s\n\n'%book_title + report,
output_format='html4'))
self.bb.button(self.bb.Close).setFocus(Qt.OtherFocusReason)
self.backup_msg.setVisible(bool(fmts))
if fmts:
m = ngettext('The original file has been saved as %s.',
'The original files have been saved as %s.', len(fmts))%(
_(' and ').join('ORIGINAL_'+f for f in fmts)
)
self.backup_msg.setText(m + ' ' + _(
'If you polish again, the polishing will run on the originals.')%(
))
def view_log(self):
self.view.setPlainText(self.current_log)
self.view.verticalScrollBar().setValue(0)
def show_next(self, *args):
if not self.reports:
return
if not self.isVisible():
self.show()
self.show_report(*self.reports.pop(0))
self.setup_ign()
def accept(self):
if self.ign.isChecked():
self.reports = []
if self.reports:
self.show_next()
return
super(Report, self).accept()
def reject(self):
if self.ign.isChecked():
self.reports = []
if self.reports:
self.show_next()
return
super(Report, self).reject()
示例10: BulkBase
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
class BulkBase(Base):
@property
def gui_val(self):
if not hasattr(self, '_cached_gui_val_'):
self._cached_gui_val_ = self.getter()
return self._cached_gui_val_
def get_initial_value(self, book_ids):
values = set([])
for book_id in book_ids:
val = self.db.get_custom(book_id, num=self.col_id, index_is_id=True)
if isinstance(val, list):
val = frozenset(val)
values.add(val)
if len(values) > 1:
break
ans = None
if len(values) == 1:
ans = iter(values).next()
if isinstance(ans, frozenset):
ans = list(ans)
return ans
def initialize(self, book_ids):
self.initial_val = val = self.get_initial_value(book_ids)
val = self.normalize_db_val(val)
self.setter(val)
def commit(self, book_ids, notify=False):
if not self.a_c_checkbox.isChecked():
return
val = self.gui_val
val = self.normalize_ui_val(val)
self.db.set_custom_bulk(book_ids, val, num=self.col_id, notify=notify)
def make_widgets(self, parent, main_widget_class, extra_label_text=''):
w = QWidget(parent)
self.widgets = [QLabel('&'+self.col_metadata['name']+':', w), w]
l = QHBoxLayout()
l.setContentsMargins(0, 0, 0, 0)
w.setLayout(l)
self.main_widget = main_widget_class(w)
l.addWidget(self.main_widget)
l.setStretchFactor(self.main_widget, 10)
self.a_c_checkbox = QCheckBox(_('Apply changes'), w)
l.addWidget(self.a_c_checkbox)
self.ignore_change_signals = True
# connect to the various changed signals so we can auto-update the
# apply changes checkbox
if hasattr(self.main_widget, 'editTextChanged'):
# editable combobox widgets
self.main_widget.editTextChanged.connect(self.a_c_checkbox_changed)
if hasattr(self.main_widget, 'textChanged'):
# lineEdit widgets
self.main_widget.textChanged.connect(self.a_c_checkbox_changed)
if hasattr(self.main_widget, 'currentIndexChanged'):
# combobox widgets
self.main_widget.currentIndexChanged[int].connect(self.a_c_checkbox_changed)
if hasattr(self.main_widget, 'valueChanged'):
# spinbox widgets
self.main_widget.valueChanged.connect(self.a_c_checkbox_changed)
if hasattr(self.main_widget, 'dateTimeChanged'):
# dateEdit widgets
self.main_widget.dateTimeChanged.connect(self.a_c_checkbox_changed)
def a_c_checkbox_changed(self):
if not self.ignore_change_signals:
self.a_c_checkbox.setChecked(True)
示例11: MakeBrickDialog
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
class MakeBrickDialog(QDialog):
def __init__(self, parent, modal=True, flags=Qt.WindowFlags()):
QDialog.__init__(self, parent, flags)
self.setModal(modal)
self.setWindowTitle("Convert sources to FITS brick")
lo = QVBoxLayout(self)
lo.setMargin(10)
lo.setSpacing(5)
# file selector
self.wfile = FileSelector(self, label="FITS filename:", dialog_label="Output FITS file", default_suffix="fits",
file_types="FITS files (*.fits *.FITS)", file_mode=QFileDialog.ExistingFile)
lo.addWidget(self.wfile)
# reference frequency
lo1 = QHBoxLayout()
lo.addLayout(lo1)
lo1.setContentsMargins(0, 0, 0, 0)
label = QLabel("Frequency, MHz:", self)
lo1.addWidget(label)
tip = """<P>If your sky model contains spectral information (such as spectral indices), then a brick may be generated
for a specific frequency. If a frequency is not specified here, the reference frequency of the model sources will be assumed.</P>"""
self.wfreq = QLineEdit(self)
self.wfreq.setValidator(QDoubleValidator(self))
label.setToolTip(tip)
self.wfreq.setToolTip(tip)
lo1.addWidget(self.wfreq)
# beam gain
lo1 = QHBoxLayout()
lo.addLayout(lo1)
lo1.setContentsMargins(0, 0, 0, 0)
self.wpb_apply = QCheckBox("Apply primary beam expression:", self)
self.wpb_apply.setChecked(True)
lo1.addWidget(self.wpb_apply)
tip = """<P>If this option is specified, a primary power beam gain will be applied to the sources before inserting
them into the brick. This can be any valid Python expression making use of the variables 'r' (corresponding
to distance from field centre, in radians) and 'fq' (corresponding to frequency.)</P>"""
self.wpb_exp = QLineEdit(self)
self.wpb_apply.setToolTip(tip)
self.wpb_exp.setToolTip(tip)
lo1.addWidget(self.wpb_exp)
# overwrite or add mode
lo1 = QHBoxLayout()
lo.addLayout(lo1)
lo1.setContentsMargins(0, 0, 0, 0)
self.woverwrite = QRadioButton("overwrite image", self)
self.woverwrite.setChecked(True)
lo1.addWidget(self.woverwrite)
self.waddinto = QRadioButton("add into image", self)
lo1.addWidget(self.waddinto)
# add to model
self.wadd = QCheckBox("Add resulting brick to sky model as a FITS image component", self)
lo.addWidget(self.wadd)
lo1 = QHBoxLayout()
lo.addLayout(lo1)
lo1.setContentsMargins(0, 0, 0, 0)
self.wpad = QLineEdit(self)
self.wpad.setValidator(QDoubleValidator(self))
self.wpad.setText("1.1")
lab = QLabel("...with padding factor:", self)
lab.setToolTip("""<P>The padding factor determines the amount of null padding inserted around the image during
the prediction stage. Padding alleviates the effects of tapering and detapering in the uv-brick, which can show
up towards the edges of the image. For a factor of N, the image will be padded out to N times its original size.
This increases memory use, so if you have no flux at the edges of the image anyway, then a pad factor of 1 is
perfectly fine.</P>""")
self.wpad.setToolTip(lab.toolTip())
QObject.connect(self.wadd, SIGNAL("toggled(bool)"), self.wpad.setEnabled)
QObject.connect(self.wadd, SIGNAL("toggled(bool)"), lab.setEnabled)
self.wpad.setEnabled(False)
lab.setEnabled(False)
lo1.addStretch(1)
lo1.addWidget(lab, 0)
lo1.addWidget(self.wpad, 1)
self.wdel = QCheckBox("Remove from the sky model sources that go into the brick", self)
lo.addWidget(self.wdel)
# OK/cancel buttons
lo.addSpacing(10)
lo2 = QHBoxLayout()
lo.addLayout(lo2)
lo2.setContentsMargins(0, 0, 0, 0)
lo2.setMargin(5)
self.wokbtn = QPushButton("OK", self)
self.wokbtn.setMinimumWidth(128)
QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept)
self.wokbtn.setEnabled(False)
cancelbtn = QPushButton("Cancel", self)
cancelbtn.setMinimumWidth(128)
QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject)
lo2.addWidget(self.wokbtn)
lo2.addStretch(1)
lo2.addWidget(cancelbtn)
self.setMinimumWidth(384)
# signals
QObject.connect(self.wfile, SIGNAL("filenameSelected"), self._fileSelected)
# internal state
self.qerrmsg = QErrorMessage(self)
def setModel(self, model):
self.model = model
pb = self.model.primaryBeam()
if pb:
self.wpb_exp.setText(pb)
#.........这里部分代码省略.........
示例12: ConfigWidget
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
#.........这里部分代码省略.........
flesch_reading_column_label = QLabel('&Flesch Reading Ease:', self)
flesch_reading_column_label.setToolTip('Specify the custom column to store a computed Flesch Reading Ease score.\n'
'Leave this blank if you do not want to calculate it')
flesch_reading_col = library_config.get(KEY_FLESCH_READING_CUSTOM_COLUMN, '')
self.flesch_reading_column_combo = CustomColumnComboBox(self, avail_columns, flesch_reading_col)
flesch_reading_column_label.setBuddy(self.flesch_reading_column_combo)
readability_layout.addWidget(flesch_reading_column_label, 1, 0, 1, 1)
readability_layout.addWidget(self.flesch_reading_column_combo, 1, 1, 1, 2)
flesch_grade_column_label = QLabel('Flesch-&Kincaid Grade:', self)
flesch_grade_column_label.setToolTip('Specify the custom column to store a computed Flesch-Kincaid Grade Level score.\n'
'Leave this blank if you do not want to calculate it')
flesch_grade_col = library_config.get(KEY_FLESCH_GRADE_CUSTOM_COLUMN, '')
self.flesch_grade_column_combo = CustomColumnComboBox(self, avail_columns, flesch_grade_col)
flesch_grade_column_label.setBuddy(self.flesch_grade_column_combo)
readability_layout.addWidget(flesch_grade_column_label, 2, 0, 1, 1)
readability_layout.addWidget(self.flesch_grade_column_combo, 2, 1, 1, 2)
gunning_fog_column_label = QLabel('&Gunning Fox Index:', self)
gunning_fog_column_label.setToolTip('Specify the custom column to store a computed Gunning Fog Index score.\n'
'Leave this blank if you do not want to calculate it')
gunning_fog_col = library_config.get(KEY_GUNNING_FOG_CUSTOM_COLUMN, '')
self.gunning_fog_column_combo = CustomColumnComboBox(self, avail_columns, gunning_fog_col)
gunning_fog_column_label.setBuddy(self.gunning_fog_column_combo)
readability_layout.addWidget(gunning_fog_column_label, 3, 0, 1, 1)
readability_layout.addWidget(self.gunning_fog_column_combo, 3, 1, 1, 2)
# --- Other options ---
layout.addSpacing(5)
other_group_box = QGroupBox('Other options:', self)
layout.addWidget(other_group_box)
other_group_box_layout = QGridLayout()
other_group_box.setLayout(other_group_box_layout)
button_default_label = QLabel('&Button default:', self)
button_default_label.setToolTip('If plugin is placed as a toolbar button, choose a default action when clicked on')
self.button_default_combo = KeyValueComboBox(self, BUTTON_DEFAULTS, button_default)
button_default_label.setBuddy(self.button_default_combo)
other_group_box_layout.addWidget(button_default_label, 0, 0, 1, 1)
other_group_box_layout.addWidget(self.button_default_combo, 0, 1, 1, 2)
self.overwrite_checkbox = QCheckBox('Always overwrite an existing word/page count', self)
self.overwrite_checkbox.setToolTip('Uncheck this option if you have manually populated values in\n'
'either of your page/word custom columns, and never want the\n'
'plugin to overwrite it. Acts as a convenience option for users\n'
'who have the toolbar button configured to populate both page\n'
'and word count, but for some books have already assigned values\n'
'into a column and just want the zero/blank column populated.')
self.overwrite_checkbox.setChecked(overwrite_existing)
other_group_box_layout.addWidget(self.overwrite_checkbox, 1, 0, 1, 3)
keyboard_shortcuts_button = QPushButton('Keyboard shortcuts...', self)
keyboard_shortcuts_button.setToolTip(_(
'Edit the keyboard shortcuts associated with this plugin'))
keyboard_shortcuts_button.clicked.connect(self.edit_shortcuts)
view_prefs_button = QPushButton('&View library preferences...', self)
view_prefs_button.setToolTip(_(
'View data stored in the library database for this plugin'))
view_prefs_button.clicked.connect(self.view_prefs)
layout.addWidget(keyboard_shortcuts_button)
layout.addWidget(view_prefs_button)
layout.addStretch(1)
def save_settings(self):
new_prefs = {}
new_prefs[KEY_BUTTON_DEFAULT] = self.button_default_combo.selected_key()
new_prefs[KEY_OVERWRITE_EXISTING] = self.overwrite_checkbox.isChecked()
plugin_prefs[STORE_NAME] = new_prefs
db = self.plugin_action.gui.current_db
library_config = get_library_config(db)
library_config[KEY_PAGES_ALGORITHM] = self.page_algorithm_combo.currentIndex()
library_config[KEY_PAGES_CUSTOM_COLUMN] = self.page_column_combo.get_selected_column()
library_config[KEY_WORDS_CUSTOM_COLUMN] = self.word_column_combo.get_selected_column()
library_config[KEY_FLESCH_READING_CUSTOM_COLUMN] = self.flesch_reading_column_combo.get_selected_column()
library_config[KEY_FLESCH_GRADE_CUSTOM_COLUMN] = self.flesch_grade_column_combo.get_selected_column()
library_config[KEY_GUNNING_FOG_CUSTOM_COLUMN] = self.gunning_fog_column_combo.get_selected_column()
set_library_config(db, library_config)
def get_custom_columns(self):
column_types = ['float','int']
custom_columns = self.plugin_action.gui.library_view.model().custom_columns
available_columns = {}
for key, column in custom_columns.iteritems():
typ = column['datatype']
if typ in column_types:
available_columns[key] = column
return available_columns
def _link_activated(self, url):
open_url(QUrl(url))
def edit_shortcuts(self):
d = KeyboardConfigDialog(self.plugin_action.gui, self.plugin_action.action_spec[0])
if d.exec_() == d.Accepted:
self.plugin_action.gui.keyboard.finalize()
def view_prefs(self):
d = PrefsViewerDialog(self.plugin_action.gui, PREFS_NAMESPACE)
d.exec_()
示例13: RuleEditor
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
#.........这里部分代码省略.........
m.clear()
for name in self.icon_file_names:
m.addAction(QIcon(os.path.join(self.icon_folder, name)), name).triggered.connect(partial(
self.remove_image, name))
def remove_image(self, name):
try:
os.remove(os.path.join(self.icon_folder, name))
except EnvironmentError:
pass
else:
self.populate_icon_filenames()
self.update_remove_button()
self.update_filename_box()
self.update_icon_filenames_in_box()
def add_blank_condition(self):
c = ConditionEditor(self.fm, parent=self.conditions_widget)
self.conditions.append(c)
self.conditions_widget.layout().addWidget(c)
def apply_rule(self, kind, col, rule):
if kind == 'color':
if rule.color:
self.color_box.color = rule.color
else:
if self.rule_kind == 'icon':
for i, tup in enumerate(icon_rule_kinds):
if kind == tup[1]:
self.kind_box.setCurrentIndex(i)
break
self.rule_icon_files = [ic.strip() for ic in rule.color.split(':')]
if len(self.rule_icon_files) > 1:
self.multiple_icon_cb.setChecked(True)
self.update_filename_box()
self.update_icon_filenames_in_box()
for i in range(self.column_box.count()):
c = unicode(self.column_box.itemData(i).toString())
if col == c:
self.column_box.setCurrentIndex(i)
break
for c in rule.conditions:
ce = ConditionEditor(self.fm, parent=self.conditions_widget)
self.conditions.append(ce)
self.conditions_widget.layout().addWidget(ce)
try:
ce.condition = c
except:
import traceback
traceback.print_exc()
def accept(self):
if self.rule_kind != 'color':
fname = self.get_filenames_from_box()
if not fname:
error_dialog(self, _('No icon selected'),
_('You must choose an icon for this rule'), show=True)
return
if self.validate():
QDialog.accept(self)
def validate(self):
r = Rule(self.fm)
for c in self.conditions:
示例14: JobError
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
#.........这里部分代码省略.........
self.setWindowIcon(self.icon)
self.icon_label = QLabel()
self.icon_label.setPixmap(self.icon.pixmap(68, 68))
self.icon_label.setMaximumSize(QSize(68, 68))
self.msg_label = QLabel('<p> ')
self.msg_label.setStyleSheet('QLabel { margin-top: 1ex; }')
self.msg_label.setWordWrap(True)
self.msg_label.setTextFormat(Qt.RichText)
self.det_msg = QPlainTextEdit(self)
self.det_msg.setVisible(False)
self.bb = QDialogButtonBox(QDialogButtonBox.Close, parent=self)
self.bb.accepted.connect(self.accept)
self.bb.rejected.connect(self.reject)
self.ctc_button = self.bb.addButton(_('&Copy to clipboard'),
self.bb.ActionRole)
self.ctc_button.clicked.connect(self.copy_to_clipboard)
self.show_det_msg = _('Show &details')
self.hide_det_msg = _('Hide &details')
self.det_msg_toggle = self.bb.addButton(self.show_det_msg, self.bb.ActionRole)
self.det_msg_toggle.clicked.connect(self.toggle_det_msg)
self.det_msg_toggle.setToolTip(
_('Show detailed information about this error'))
self.suppress = QCheckBox(self)
l.addWidget(self.icon_label, 0, 0, 1, 1)
l.addWidget(self.msg_label, 0, 1, 1, 1)
l.addWidget(self.det_msg, 1, 0, 1, 2)
l.addWidget(self.suppress, 2, 0, 1, 2, Qt.AlignLeft|Qt.AlignBottom)
l.addWidget(self.bb, 3, 0, 1, 2, Qt.AlignRight|Qt.AlignBottom)
l.setColumnStretch(1, 100)
self.setModal(False)
self.suppress.setVisible(False)
self.do_resize()
def update_suppress_state(self):
self.suppress.setText(_(
'Hide the remaining %d error messages'%len(self.queue)))
self.suppress.setVisible(len(self.queue) > 3)
self.do_resize()
def copy_to_clipboard(self, *args):
d = QTextDocument()
d.setHtml(self.msg_label.text())
QApplication.clipboard().setText(
u'calibre, version %s (%s, isfrozen: %s)\n%s: %s\n\n%s' %
(__version__, sys.platform, isfrozen,
unicode(self.windowTitle()), unicode(d.toPlainText()),
unicode(self.det_msg.toPlainText())))
if hasattr(self, 'ctc_button'):
self.ctc_button.setText(_('Copied'))
def toggle_det_msg(self, *args):
vis = unicode(self.det_msg_toggle.text()) == self.hide_det_msg
self.det_msg_toggle.setText(self.show_det_msg if vis else
self.hide_det_msg)
self.det_msg.setVisible(not vis)
self.do_resize()
def do_resize(self):
h = self.sizeHint().height()
self.setMinimumHeight(0) # Needed as this gets set if det_msg is shown
# Needed otherwise re-showing the box after showing det_msg causes the box
# to not reduce in height
self.setMaximumHeight(h)
self.resize(QSize(self.WIDTH, h))
def showEvent(self, ev):
ret = QDialog.showEvent(self, ev)
self.bb.button(self.bb.Close).setFocus(Qt.OtherFocusReason)
return ret
def show_error(self, title, msg, det_msg=u''):
self.queue.append((title, msg, det_msg))
self.update_suppress_state()
self.pop()
def pop(self):
if not self.queue or self.isVisible():
return
title, msg, det_msg = self.queue.pop(0)
self.setWindowTitle(title)
self.msg_label.setText(msg)
self.det_msg.setPlainText(det_msg)
self.det_msg.setVisible(False)
self.det_msg_toggle.setText(self.show_det_msg)
self.det_msg_toggle.setVisible(True)
self.suppress.setChecked(False)
self.update_suppress_state()
if not det_msg:
self.det_msg_toggle.setVisible(False)
self.do_resize()
self.show()
def done(self, r):
if self.suppress.isChecked():
self.queue = []
QDialog.done(self, r)
self.do_pop.emit()
示例15: ConfigWidget
# 需要导入模块: from PyQt4.Qt import QCheckBox [as 别名]
# 或者: from PyQt4.Qt.QCheckBox import setChecked [as 别名]
#.........这里部分代码省略.........
self.cfg_debug_options_qvl = QVBoxLayout(self.cfg_debug_options_gb)
# ++++++++ Debug logging checkboxes ++++++++
self.debug_plugin_checkbox = QCheckBox('Enable debug logging for Marvin XD')
self.debug_plugin_checkbox.setObjectName('debug_plugin_checkbox')
self.debug_plugin_checkbox.setToolTip('Print plugin diagnostic messages to console')
self.cfg_debug_options_qvl.addWidget(self.debug_plugin_checkbox)
self.debug_libimobiledevice_checkbox = QCheckBox('Enable debug logging for libiMobileDevice')
self.debug_libimobiledevice_checkbox.setObjectName('debug_libimobiledevice_checkbox')
self.debug_libimobiledevice_checkbox.setToolTip('Print libiMobileDevice diagnostic messages to console')
self.cfg_debug_options_qvl.addWidget(self.debug_libimobiledevice_checkbox)
self.spacerItem2 = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.column2_layout.addItem(self.spacerItem2)
# ~~~~~~~~ End of construction zone ~~~~~~~~
self.resize(self.sizeHint())
# ~~~~~~~~ Populate/restore config options ~~~~~~~~
# Annotations comboBox
self.populate_annotations()
self.populate_collections()
self.populate_date_read()
self.populate_locked()
self.populate_progress()
self.populate_read()
self.populate_reading_list()
self.populate_word_count()
"""
# Restore Dropbox settings, hook changes
dropbox_syncing = self.prefs.get('dropbox_syncing', False)
self.dropbox_syncing_checkbox.setChecked(dropbox_syncing)
self.set_dropbox_syncing(dropbox_syncing)
self.dropbox_syncing_checkbox.clicked.connect(partial(self.set_dropbox_syncing))
self.dropbox_location_lineedit.setText(self.prefs.get('dropbox_folder', ''))
"""
# Restore general settings
self.duplicate_markers_checkbox.setChecked(self.prefs.get('apply_markers_to_duplicates', True))
self.updated_markers_checkbox.setChecked(self.prefs.get('apply_markers_to_updated', True))
self.auto_refresh_checkbox.setChecked(self.prefs.get('auto_refresh_at_startup', False))
self.reading_progress_checkbox.setChecked(self.prefs.get('show_progress_as_percentage', False))
# Restore debug settings, hook changes
self.debug_plugin_checkbox.setChecked(self.prefs.get('debug_plugin', False))
self.debug_plugin_checkbox.stateChanged.connect(self.set_restart_required)
self.debug_libimobiledevice_checkbox.setChecked(self.prefs.get('debug_libimobiledevice', False))
self.debug_libimobiledevice_checkbox.stateChanged.connect(self.set_restart_required)
# Hook changes to Annotations comboBox
# self.annotations_field_comboBox.currentIndexChanged.connect(
# partial(self.save_combobox_setting, 'annotations_field_comboBox'))
self.connect(self.annotations_field_comboBox,
SIGNAL('currentIndexChanged(const QString &)'),
self.annotations_destination_changed)
# Launch the annotated_books_scanner
field = get_cc_mapping('annotations', 'field', None)
self.annotated_books_scanner = InventoryAnnotatedBooks(self.gui, field)
self.connect(self.annotated_books_scanner, self.annotated_books_scanner.signal,
self.inventory_complete)
QTimer.singleShot(1, self.start_inventory)
def annotations_destination_changed(self, qs_new_destination_name):