本文整理汇总了Python中PyQt5.Qt.QTabWidget类的典型用法代码示例。如果您正苦于以下问题:Python QTabWidget类的具体用法?Python QTabWidget怎么用?Python QTabWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTabWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, filesystem_cache, show_files=True):
QTabWidget.__init__(self)
self.fs = filesystem_cache
for storage in self.fs.entries:
w = Storage(storage, show_files)
self.addTab(w, w.name)
w.doubleClicked.connect(self.selected)
self.setCurrentIndex(0)
示例2: __init__
def __init__(self, plugin_action):
QWidget.__init__(self)
self.plugin_action = plugin_action
self.l = QVBoxLayout()
self.setLayout(self.l)
tab_widget = QTabWidget(self)
self.l.addWidget(tab_widget)
self.basic_tab = BasicTab(self, plugin_action)
tab_widget.addTab(self.basic_tab, _('Basic'))
self.columns_tab = ColumnsTab(self, plugin_action)
tab_widget.addTab(self.columns_tab, _('Columns'))
示例3: __init__
def __init__(self, parent=None):
super(PanelQWidget, self).__init__(parent)
self.setAcceptDrops(True)
# Fields
self.tab_widget = QTabWidget()
self.layout = QVBoxLayout()
self.dashboard_widget = DashboardQWidget()
self.synthesis_widget = SynthesisQWidget()
self.problems_widget = ProblemsQWidget()
self.spy_widget = SpyQWidget()
self.hostnames_list = []
示例4: Dialog
class Dialog(QtWidgets.QDialog):
_layout = None
buttonBox = None
okButtonText = None
cancelButtonText = None
okButton = None
cancelButton = None
_tab = None
def __init__(self, title=None, f=None, desc=None):
# FIXME: f no lo uso , es qt.windowsflg
super(Dialog, self).__init__()
if title:
self.setWindowTitle(str(title))
self.setWindowModality(QtCore.Qt.ApplicationModal)
self._layout = QtWidgets.QVBoxLayout()
self.setLayout(self._layout)
self.buttonBox = QtWidgets.QDialogButtonBox()
self.okButton = QtWidgets.QPushButton("&Aceptar")
self.cancelButton = QtWidgets.QPushButton("&Cancelar")
self.buttonBox.addButton(
self.okButton, QtWidgets.QDialogButtonBox.AcceptRole)
self.buttonBox.addButton(
self.cancelButton, QtWidgets.QDialogButtonBox.RejectRole)
self.okButton.clicked.connect(self.accept)
self.cancelButton.clicked.connect(self.reject)
from PyQt5.Qt import QTabWidget
self._tab = QTabWidget()
self._tab.hide()
self._layout.addWidget(self._tab)
self.oKButtonText = None
self.cancelButtonText = None
def add(self, _object):
self._layout.addWidget(_object)
def exec_(self):
if self.okButtonText:
self.okButton.setText(str(self.okButtonText))
if (self.cancelButtonText):
self.cancelButton.setText(str(self.cancelButtonText))
self._layout.addWidget(self.buttonBox)
return super(Dialog, self).exec_()
def newTab(self, name):
if self._tab.isHidden():
self._tab.show()
self._tab.addTab(QtWidgets.QWidget(), str(name))
def __getattr__(self, name):
if name == "caption":
name = self.setWindowTitle
return getattr(super(Dialog, self), name)
示例5: do_config
def do_config(self):
# Save values that need to be synced between the dialog and the
# search widget.
self.config['open_external'] = self.open_external.isChecked()
# Create the config dialog. It's going to put two config widgets
# into a QTabWidget for displaying all of the settings.
d = QDialog(self)
button_box = QDialogButtonBox(QDialogButtonBox.Close)
v = QVBoxLayout(d)
button_box.accepted.connect(d.accept)
button_box.rejected.connect(d.reject)
d.setWindowTitle(_('Customize Get books search'))
tab_widget = QTabWidget(d)
v.addWidget(tab_widget)
v.addWidget(button_box)
chooser_config_widget = StoreChooserWidget()
search_config_widget = StoreConfigWidget(self.config)
tab_widget.addTab(chooser_config_widget, _('Choose s&tores'))
tab_widget.addTab(search_config_widget, _('Configure s&earch'))
# Restore dialog state.
geometry = self.config.get('config_dialog_geometry', None)
if geometry:
d.restoreGeometry(geometry)
else:
d.resize(800, 600)
tab_index = self.config.get('config_dialog_tab_index', 0)
tab_index = min(tab_index, tab_widget.count() - 1)
tab_widget.setCurrentIndex(tab_index)
d.exec_()
# Save dialog state.
self.config['config_dialog_geometry'] = bytearray(d.saveGeometry())
self.config['config_dialog_tab_index'] = tab_widget.currentIndex()
search_config_widget.save_settings()
self.config_changed()
self.gui.load_store_plugins()
self.setup_store_checks()
示例6: __init__
def __init__(self, title=None, f=None, desc=None):
# FIXME: f no lo uso , es qt.windowsflg
super(Dialog, self).__init__()
if title:
self.setWindowTitle(str(title))
self.setWindowModality(QtCore.Qt.ApplicationModal)
self._layout = QtWidgets.QVBoxLayout()
self.setLayout(self._layout)
self.buttonBox = QtWidgets.QDialogButtonBox()
self.okButton = QtWidgets.QPushButton("&Aceptar")
self.cancelButton = QtWidgets.QPushButton("&Cancelar")
self.buttonBox.addButton(
self.okButton, QtWidgets.QDialogButtonBox.AcceptRole)
self.buttonBox.addButton(
self.cancelButton, QtWidgets.QDialogButtonBox.RejectRole)
self.okButton.clicked.connect(self.accept)
self.cancelButton.clicked.connect(self.reject)
from PyQt5.Qt import QTabWidget
self._tab = QTabWidget()
self._tab.hide()
self._layout.addWidget(self._tab)
self.oKButtonText = None
self.cancelButtonText = None
示例7: IgnoredFolders
class IgnoredFolders(QDialog):
def __init__(self, dev, ignored_folders=None, parent=None):
QDialog.__init__(self, parent)
self.l = l = QVBoxLayout()
self.setLayout(l)
self.la = la = QLabel('<p>'+ _('<b>Scanned folders:</b>') + ' ' +
_('You can select which folders calibre will '
'scan when searching this device for books.'))
la.setWordWrap(True)
l.addWidget(la)
self.tabs = QTabWidget(self)
l.addWidget(self.tabs)
self.widgets = []
for storage in dev.filesystem_cache.entries:
self.dev = dev
w = Storage(storage, item_func=self.create_item)
del self.dev
self.tabs.addTab(w, storage.name)
self.widgets.append(w)
w.itemChanged.connect(self.item_changed)
self.la2 = la = QLabel(_(
'If you a select a previously unselected folder, any sub-folders'
' will not be visible until you restart calibre.'))
l.addWidget(la)
la.setWordWrap(True)
self.bb = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
self.bb.accepted.connect(self.accept)
self.bb.rejected.connect(self.reject)
self.sab = self.bb.addButton(_('Select &All'), self.bb.ActionRole)
self.sab.clicked.connect(self.select_all)
self.snb = self.bb.addButton(_('Select &None'), self.bb.ActionRole)
self.snb.clicked.connect(self.select_none)
l.addWidget(self.bb)
self.setWindowTitle(_('Choose folders to scan'))
self.setWindowIcon(QIcon(I('devices/tablet.png')))
self.resize(600, 500)
def item_changed(self, item, column):
w = item.treeWidget()
root = w.invisibleRootItem()
w.itemChanged.disconnect(self.item_changed)
try:
if item.checkState(0) == Qt.Checked:
# Ensure that the parents of this item are checked
p = item.parent()
while p is not None and p is not root:
p.setCheckState(0, Qt.Checked)
p = p.parent()
# Set the state of all descendants to the same state as this item
for child in self.iterchildren(item):
child.setCheckState(0, item.checkState(0))
finally:
w.itemChanged.connect(self.item_changed)
def iterchildren(self, node):
' Iterate over all descendants of node '
for i in xrange(node.childCount()):
child = node.child(i)
yield child
for gc in self.iterchildren(child):
yield gc
def create_item(self, f, parent):
name = f.name
ans = QTreeWidgetItem(parent, [name])
ans.setData(0, Qt.UserRole, '/'.join(f.full_path[1:]))
ans.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
ans.setCheckState(0,
Qt.Unchecked if self.dev.is_folder_ignored(f.storage_id, f.full_path[1:]) else Qt.Checked)
ans.setData(0, Qt.DecorationRole, file_icon_provider().icon_from_ext('dir'))
return ans
def select_all(self):
w = self.tabs.currentWidget()
for i in xrange(w.invisibleRootItem().childCount()):
c = w.invisibleRootItem().child(i)
c.setCheckState(0, Qt.Checked)
def select_none(self):
w = self.tabs.currentWidget()
for i in xrange(w.invisibleRootItem().childCount()):
c = w.invisibleRootItem().child(i)
c.setCheckState(0, Qt.Unchecked)
@property
def ignored_folders(self):
ans = {}
for w in self.widgets:
folders = set()
for node in self.iterchildren(w.invisibleRootItem()):
if node.checkState(0) == Qt.Checked:
continue
path = unicode(node.data(0, Qt.UserRole) or '')
parent = path.rpartition('/')[0]
#.........这里部分代码省略.........
示例8: __init__
def __init__(self, parent=None, one_line_toolbar=False):
QWidget.__init__(self, parent)
self.toolbar1 = QToolBar(self)
self.toolbar2 = QToolBar(self)
self.toolbar3 = QToolBar(self)
for i in range(1, 4):
t = getattr(self, 'toolbar%d'%i)
t.setIconSize(QSize(18, 18))
self.editor = EditorWidget(self)
self.set_html = self.editor.set_html
self.tabs = QTabWidget(self)
self.tabs.setTabPosition(self.tabs.South)
self.wyswyg = QWidget(self.tabs)
self.code_edit = QPlainTextEdit(self.tabs)
self.source_dirty = False
self.wyswyg_dirty = True
self._layout = QVBoxLayout(self)
self.wyswyg.layout = l = QVBoxLayout(self.wyswyg)
self.setLayout(self._layout)
l.setContentsMargins(0, 0, 0, 0)
if one_line_toolbar:
tb = QHBoxLayout()
l.addLayout(tb)
else:
tb = l
tb.addWidget(self.toolbar1)
tb.addWidget(self.toolbar2)
tb.addWidget(self.toolbar3)
l.addWidget(self.editor)
self._layout.addWidget(self.tabs)
self.tabs.addTab(self.wyswyg, _('N&ormal view'))
self.tabs.addTab(self.code_edit, _('&HTML Source'))
self.tabs.currentChanged[int].connect(self.change_tab)
self.highlighter = Highlighter(self.code_edit.document())
self.layout().setContentsMargins(0, 0, 0, 0)
# toolbar1 {{{
self.toolbar1.addAction(self.editor.action_undo)
self.toolbar1.addAction(self.editor.action_redo)
self.toolbar1.addAction(self.editor.action_select_all)
self.toolbar1.addAction(self.editor.action_remove_format)
self.toolbar1.addAction(self.editor.action_clear)
self.toolbar1.addSeparator()
for x in ('copy', 'cut', 'paste'):
ac = getattr(self.editor, 'action_'+x)
self.toolbar1.addAction(ac)
self.toolbar1.addSeparator()
self.toolbar1.addAction(self.editor.action_background)
# }}}
# toolbar2 {{{
for x in ('', 'un'):
ac = getattr(self.editor, 'action_%sordered_list'%x)
self.toolbar2.addAction(ac)
self.toolbar2.addSeparator()
for x in ('superscript', 'subscript', 'indent', 'outdent'):
self.toolbar2.addAction(getattr(self.editor, 'action_' + x))
if x in ('subscript', 'outdent'):
self.toolbar2.addSeparator()
self.toolbar2.addAction(self.editor.action_block_style)
w = self.toolbar2.widgetForAction(self.editor.action_block_style)
w.setPopupMode(w.InstantPopup)
self.toolbar2.addAction(self.editor.action_insert_link)
# }}}
# toolbar3 {{{
for x in ('bold', 'italic', 'underline', 'strikethrough'):
ac = getattr(self.editor, 'action_'+x)
self.toolbar3.addAction(ac)
self.toolbar3.addSeparator()
for x in ('left', 'center', 'right', 'justified'):
ac = getattr(self.editor, 'action_align_'+x)
self.toolbar3.addAction(ac)
self.toolbar3.addSeparator()
self.toolbar3.addAction(self.editor.action_color)
# }}}
self.code_edit.textChanged.connect(self.code_dirtied)
self.editor.page().contentsChanged.connect(self.wyswyg_dirtied)
示例9: Editor
class Editor(QWidget): # {{{
def __init__(self, parent=None, one_line_toolbar=False):
QWidget.__init__(self, parent)
self.toolbar1 = QToolBar(self)
self.toolbar2 = QToolBar(self)
self.toolbar3 = QToolBar(self)
for i in range(1, 4):
t = getattr(self, 'toolbar%d'%i)
t.setIconSize(QSize(18, 18))
self.editor = EditorWidget(self)
self.set_html = self.editor.set_html
self.tabs = QTabWidget(self)
self.tabs.setTabPosition(self.tabs.South)
self.wyswyg = QWidget(self.tabs)
self.code_edit = QPlainTextEdit(self.tabs)
self.source_dirty = False
self.wyswyg_dirty = True
self._layout = QVBoxLayout(self)
self.wyswyg.layout = l = QVBoxLayout(self.wyswyg)
self.setLayout(self._layout)
l.setContentsMargins(0, 0, 0, 0)
if one_line_toolbar:
tb = QHBoxLayout()
l.addLayout(tb)
else:
tb = l
tb.addWidget(self.toolbar1)
tb.addWidget(self.toolbar2)
tb.addWidget(self.toolbar3)
l.addWidget(self.editor)
self._layout.addWidget(self.tabs)
self.tabs.addTab(self.wyswyg, _('N&ormal view'))
self.tabs.addTab(self.code_edit, _('&HTML Source'))
self.tabs.currentChanged[int].connect(self.change_tab)
self.highlighter = Highlighter(self.code_edit.document())
self.layout().setContentsMargins(0, 0, 0, 0)
# toolbar1 {{{
self.toolbar1.addAction(self.editor.action_undo)
self.toolbar1.addAction(self.editor.action_redo)
self.toolbar1.addAction(self.editor.action_select_all)
self.toolbar1.addAction(self.editor.action_remove_format)
self.toolbar1.addAction(self.editor.action_clear)
self.toolbar1.addSeparator()
for x in ('copy', 'cut', 'paste'):
ac = getattr(self.editor, 'action_'+x)
self.toolbar1.addAction(ac)
self.toolbar1.addSeparator()
self.toolbar1.addAction(self.editor.action_background)
# }}}
# toolbar2 {{{
for x in ('', 'un'):
ac = getattr(self.editor, 'action_%sordered_list'%x)
self.toolbar2.addAction(ac)
self.toolbar2.addSeparator()
for x in ('superscript', 'subscript', 'indent', 'outdent'):
self.toolbar2.addAction(getattr(self.editor, 'action_' + x))
if x in ('subscript', 'outdent'):
self.toolbar2.addSeparator()
self.toolbar2.addAction(self.editor.action_block_style)
w = self.toolbar2.widgetForAction(self.editor.action_block_style)
w.setPopupMode(w.InstantPopup)
self.toolbar2.addAction(self.editor.action_insert_link)
# }}}
# toolbar3 {{{
for x in ('bold', 'italic', 'underline', 'strikethrough'):
ac = getattr(self.editor, 'action_'+x)
self.toolbar3.addAction(ac)
self.toolbar3.addSeparator()
for x in ('left', 'center', 'right', 'justified'):
ac = getattr(self.editor, 'action_align_'+x)
self.toolbar3.addAction(ac)
self.toolbar3.addSeparator()
self.toolbar3.addAction(self.editor.action_color)
# }}}
self.code_edit.textChanged.connect(self.code_dirtied)
self.editor.page().contentsChanged.connect(self.wyswyg_dirtied)
def set_minimum_height_for_editor(self, val):
self.editor.setMinimumHeight(val)
@dynamic_property
def html(self):
def fset(self, v):
self.editor.html = v
def fget(self):
self.tabs.setCurrentIndex(0)
return self.editor.html
return property(fget=fget, fset=fset)
def change_tab(self, index):
#.........这里部分代码省略.........
示例10: __init__
def __init__(self, device, parent=None, highlight_ignored_folders=False):
QTabWidget.__init__(self, parent)
self._device = weakref.ref(device)
cd = msg = None
if device.current_friendly_name is not None:
if device.current_serial_num is None:
msg = '<p>' + (_('The <b>%s</b> device has no serial number, '
'it cannot be configured')%device.current_friendly_name)
else:
cd = 'device-'+device.current_serial_num
else:
msg = '<p>' + _('<b>No MTP device connected.</b><p>'
' You can only configure the MTP device plugin when a device'
' is connected.')
self.current_device_key = cd
if msg:
msg += '<p>' + _('If you want to un-ignore a previously'
' ignored MTP device, use the "Ignored devices" tab.')
l = QLabel(msg)
l.setWordWrap(True)
l.setStyleSheet('QLabel { margin-left: 2em }')
l.setMinimumWidth(500)
l.setMinimumHeight(400)
self.insertTab(0, l, _('Cannot configure'))
else:
self.base = QWidget(self)
self.insertTab(0, self.base, _('Configure %s')%self.device.current_friendly_name)
l = self.base.l = QGridLayout(self.base)
self.base.setLayout(l)
self.rules = r = FormatRules(self.device, self.get_pref('rules'))
self.formats = FormatsConfig(set(BOOK_EXTENSIONS),
self.get_pref('format_map'))
self.send_to = SendToConfig(self.get_pref('send_to'), self.device)
self.template = TemplateConfig(self.get_pref('send_template'))
self.base.la = la = QLabel(_(
'Choose the formats to send to the %s')%self.device.current_friendly_name)
la.setWordWrap(True)
self.base.b = b = QPushButton(QIcon(I('list_remove.png')),
_('&Ignore the %s in calibre')%device.current_friendly_name,
self.base)
b.clicked.connect(self.ignore_device)
self.config_ign_folders_button = cif = QPushButton(
QIcon(I('tb_folder.png')), _('Change scanned &folders'))
cif.setStyleSheet(
'QPushButton { font-weight: bold; }')
if highlight_ignored_folders:
cif.setIconSize(QSize(64, 64))
self.show_debug_button = bd = QPushButton(QIcon(I('debug.png')),
_('Show device information'))
bd.clicked.connect(self.show_debug_info)
cif.clicked.connect(self.change_ignored_folders)
l.addWidget(b, 0, 0, 1, 2)
l.addWidget(la, 1, 0, 1, 1)
l.addWidget(self.formats, 2, 0, 5, 1)
l.addWidget(cif, 2, 1, 1, 1)
l.addWidget(self.template, 3, 1, 1, 1)
l.addWidget(self.send_to, 4, 1, 1, 1)
l.addWidget(self.show_debug_button, 5, 1, 1, 1)
l.setRowStretch(6, 10)
l.addWidget(r, 7, 0, 1, 2)
l.setRowStretch(7, 100)
self.igntab = IgnoredDevices(self.device.prefs['history'],
self.device.prefs['blacklist'])
self.addTab(self.igntab, _('Ignored devices'))
self.current_ignored_folders = self.get_pref('ignored_folders')
self.initial_ignored_folders = self.current_ignored_folders
self.setCurrentIndex(1 if msg else 0)
示例11: __init__
def __init__(self, parent=None):
super(MainWin, self).__init__(parent)
self.setWindowTitle("Eilat Browser")
# gc.set_debug(gc.DEBUG_LEAK)
self.last_closed = None
self.tab_widget = QTabWidget(self)
self.tab_widget.setTabBar(MidClickTabBar(self))
self.tab_widget.tabBar().setMovable(True)
self.tab_widget.setTabsClosable(True)
# the right side of the tab already has the space for
# a non-shown close button
self.tab_widget.setStyleSheet(
'QTabBar::tab {padding-top: 0px; padding-bottom: 0px; '
'padding-left: 0.3em;} '
'QTabBar::tab:selected {color: #00f;}')
# tabCloseRequested carries int (index of a tab)
self.tab_widget.tabCloseRequested.connect(self.del_tab)
self.setCentralWidget(self.tab_widget)
self.tooltip = NotifyLabel(parent=self)
def restore_last_closed():
""" One-use callback for QShortcut.
Opens a fresh new tab with the url address of the last tab closed
"""
if self.last_closed is not None:
url = self.last_closed
self.add_tab(url)
self.last_closed = None
def dump_gc():
""" prints sizes for large memory collectable objects """
objs = gc.get_objects()
pairs = [(str(k)[:80], type(k).__name__, sys.getsizeof(k))
for k in objs if sys.getsizeof(k) > 1024*4*5]
for pair in pairs:
print(pair)
def reload_disk_init():
""" transfer options.yaml and the css directory to global maps """
load_options()
load_css()
notify("reloaded disk config")
set_shortcuts([
("F9", self, dump_gc),
# reload configuration
("Ctrl+Shift+R", self, reload_disk_init),
# new tabs
("Ctrl+T", self, self.add_tab),
("Ctrl+Shift+T", self, partial(self.add_tab, scripting=True)),
("Y", self, self.new_tab_from_clipboard),
# movement
("M", self, self.inc_tab),
("N", self, partial(self.inc_tab, -1)),
("Ctrl+PgUp", self, partial(self.inc_tab, -1)),
("Ctrl+PgDown", self, self.inc_tab),
# destroy/undestroy
("U", self, restore_last_closed),
("Ctrl+W", self, self.del_tab),
("Ctrl+Q", self, self.finalize)
])
示例12: __init__
def __init__(self, recipe_model, parent=None):
QDialog.__init__(self, parent)
self.commit_on_change = True
self.previous_urn = None
self.setWindowIcon(QIcon(I('scheduler.png')))
self.setWindowTitle(_("Schedule news download"))
self.l = l = QGridLayout(self)
# Left panel
self.h = h = QHBoxLayout()
l.addLayout(h, 0, 0, 1, 1)
self.search = s = SearchBox2(self)
self.search.initialize('scheduler_search_history')
self.search.setMinimumContentsLength(15)
self.go_button = b = QToolButton(self)
b.setText(_("Go"))
b.clicked.connect(self.search.do_search)
self.clear_search_button = cb = QToolButton(self)
self.clear_search_button.clicked.connect(self.search.clear_clicked)
cb.setIcon(QIcon(I('clear_left.png')))
h.addWidget(s), h.addWidget(b), h.addWidget(cb)
self.recipes = RecipesView(self)
l.addWidget(self.recipes, 1, 0, 1, 1)
self.recipe_model = recipe_model
self.recipe_model.do_refresh()
self.recipes.setModel(self.recipe_model)
self.recipes.setFocus(Qt.OtherFocusReason)
self.count_label = la = QLabel(_('%s news sources') % self.recipe_model.showing_count)
la.setAlignment(Qt.AlignCenter)
l.addWidget(la, 2, 0, 1, 1)
self.search.search.connect(self.recipe_model.search)
self.recipe_model.searched.connect(self.search.search_done, type=Qt.QueuedConnection)
self.recipe_model.searched.connect(self.search_done)
# Right Panel
self.scroll_area = sa = QScrollArea(self)
self.l.addWidget(sa, 0, 1, 2, 1)
sa.setFrameShape(QFrame.NoFrame)
sa.setWidgetResizable(True)
self.scroll_area_contents = sac = QWidget(self)
sa.setWidget(sac)
sac.v = v = QVBoxLayout(sac)
v.setContentsMargins(0, 0, 0, 0)
self.detail_box = QTabWidget(self)
self.detail_box.setVisible(False)
self.detail_box.setCurrentIndex(0)
v.addWidget(self.detail_box)
v.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
# First Tab (scheduling)
self.tab = QWidget()
self.detail_box.addTab(self.tab, _("&Schedule"))
self.tab.v = vt = QVBoxLayout(self.tab)
vt.setContentsMargins(0, 0, 0, 0)
self.blurb = la = QLabel('blurb')
la.setWordWrap(True), la.setOpenExternalLinks(True)
vt.addWidget(la)
vt.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
self.frame = f = QFrame(self.tab)
vt.addWidget(f)
f.setFrameShape(f.StyledPanel)
f.setFrameShadow(f.Raised)
f.v = vf = QVBoxLayout(f)
self.schedule = s = QCheckBox(_("&Schedule for download:"), f)
self.schedule.stateChanged[int].connect(self.toggle_schedule_info)
vf.addWidget(s)
f.h = h = QHBoxLayout()
vf.addLayout(h)
self.days_of_week = QRadioButton(_("&Days of week"), f)
self.days_of_month = QRadioButton(_("Da&ys of month"), f)
self.every_x_days = QRadioButton(_("Every &x days"), f)
self.days_of_week.setChecked(True)
h.addWidget(self.days_of_week), h.addWidget(self.days_of_month), h.addWidget(self.every_x_days)
self.schedule_stack = ss = QStackedWidget(f)
self.schedule_widgets = []
for key in reversed(self.SCHEDULE_TYPES):
self.schedule_widgets.insert(0, self.SCHEDULE_TYPES[key](self))
self.schedule_stack.insertWidget(0, self.schedule_widgets[0])
vf.addWidget(ss)
self.last_downloaded = la = QLabel(f)
la.setWordWrap(True)
vf.addWidget(la)
vt.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
self.account = acc = QGroupBox(self.tab)
acc.setTitle(_("&Account"))
vt.addWidget(acc)
acc.g = g = QGridLayout(acc)
acc.unla = la = QLabel(_("&Username:"))
self.username = un = QLineEdit(self)
la.setBuddy(un)
g.addWidget(la), g.addWidget(un, 0, 1)
acc.pwla = la = QLabel(_("&Password:"))
self.password = pw = QLineEdit(self)
pw.setEchoMode(QLineEdit.Password), la.setBuddy(pw)
g.addWidget(la), g.addWidget(pw, 1, 1)
self.show_password = spw = QCheckBox(_("&Show password"), self.account)
spw.stateChanged[int].connect(self.set_pw_echo_mode)
g.addWidget(spw, 2, 0, 1, 2)
self.rla = la = QLabel(_("For the scheduling to work, you must leave calibre running."))
#.........这里部分代码省略.........
示例13: SchedulerDialog
class SchedulerDialog(QDialog):
SCHEDULE_TYPES = OrderedDict([
('days_of_week', DaysOfWeek),
('days_of_month', DaysOfMonth),
('every_x_days', EveryXDays),
])
download = pyqtSignal(object)
def __init__(self, recipe_model, parent=None):
QDialog.__init__(self, parent)
self.commit_on_change = True
self.previous_urn = None
self.setWindowIcon(QIcon(I('scheduler.png')))
self.setWindowTitle(_("Schedule news download"))
self.l = l = QGridLayout(self)
# Left panel
self.h = h = QHBoxLayout()
l.addLayout(h, 0, 0, 1, 1)
self.search = s = SearchBox2(self)
self.search.initialize('scheduler_search_history')
self.search.setMinimumContentsLength(15)
self.go_button = b = QToolButton(self)
b.setText(_("Go"))
b.clicked.connect(self.search.do_search)
self.clear_search_button = cb = QToolButton(self)
self.clear_search_button.clicked.connect(self.search.clear_clicked)
cb.setIcon(QIcon(I('clear_left.png')))
h.addWidget(s), h.addWidget(b), h.addWidget(cb)
self.recipes = RecipesView(self)
l.addWidget(self.recipes, 1, 0, 1, 1)
self.recipe_model = recipe_model
self.recipe_model.do_refresh()
self.recipes.setModel(self.recipe_model)
self.recipes.setFocus(Qt.OtherFocusReason)
self.count_label = la = QLabel(_('%s news sources') % self.recipe_model.showing_count)
la.setAlignment(Qt.AlignCenter)
l.addWidget(la, 2, 0, 1, 1)
self.search.search.connect(self.recipe_model.search)
self.recipe_model.searched.connect(self.search.search_done, type=Qt.QueuedConnection)
self.recipe_model.searched.connect(self.search_done)
# Right Panel
self.scroll_area = sa = QScrollArea(self)
self.l.addWidget(sa, 0, 1, 2, 1)
sa.setFrameShape(QFrame.NoFrame)
sa.setWidgetResizable(True)
self.scroll_area_contents = sac = QWidget(self)
sa.setWidget(sac)
sac.v = v = QVBoxLayout(sac)
v.setContentsMargins(0, 0, 0, 0)
self.detail_box = QTabWidget(self)
self.detail_box.setVisible(False)
self.detail_box.setCurrentIndex(0)
v.addWidget(self.detail_box)
v.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
# First Tab (scheduling)
self.tab = QWidget()
self.detail_box.addTab(self.tab, _("&Schedule"))
self.tab.v = vt = QVBoxLayout(self.tab)
vt.setContentsMargins(0, 0, 0, 0)
self.blurb = la = QLabel('blurb')
la.setWordWrap(True), la.setOpenExternalLinks(True)
vt.addWidget(la)
vt.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
self.frame = f = QFrame(self.tab)
vt.addWidget(f)
f.setFrameShape(f.StyledPanel)
f.setFrameShadow(f.Raised)
f.v = vf = QVBoxLayout(f)
self.schedule = s = QCheckBox(_("&Schedule for download:"), f)
self.schedule.stateChanged[int].connect(self.toggle_schedule_info)
vf.addWidget(s)
f.h = h = QHBoxLayout()
vf.addLayout(h)
self.days_of_week = QRadioButton(_("&Days of week"), f)
self.days_of_month = QRadioButton(_("Da&ys of month"), f)
self.every_x_days = QRadioButton(_("Every &x days"), f)
self.days_of_week.setChecked(True)
h.addWidget(self.days_of_week), h.addWidget(self.days_of_month), h.addWidget(self.every_x_days)
self.schedule_stack = ss = QStackedWidget(f)
self.schedule_widgets = []
for key in reversed(self.SCHEDULE_TYPES):
self.schedule_widgets.insert(0, self.SCHEDULE_TYPES[key](self))
self.schedule_stack.insertWidget(0, self.schedule_widgets[0])
vf.addWidget(ss)
self.last_downloaded = la = QLabel(f)
la.setWordWrap(True)
vf.addWidget(la)
vt.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
self.account = acc = QGroupBox(self.tab)
acc.setTitle(_("&Account"))
vt.addWidget(acc)
acc.g = g = QGridLayout(acc)
acc.unla = la = QLabel(_("&Username:"))
self.username = un = QLineEdit(self)
#.........这里部分代码省略.........
示例14: __init__
def __init__(self, device_settings, all_formats, supports_subdirs,
must_read_metadata, supports_use_author_sort,
extra_customization_message, device,
extra_customization_choices=None, parent=None):
QTabWidget.__init__(self, parent)
self._device = weakref.ref(device)
self.device_settings = device_settings
self.all_formats = set(all_formats)
self.supports_subdirs = supports_subdirs
self.must_read_metadata = must_read_metadata
self.supports_use_author_sort = supports_use_author_sort
self.extra_customization_message = extra_customization_message
self.extra_customization_choices = extra_customization_choices
try:
self.device_name = device.get_gui_name()
except TypeError:
self.device_name = getattr(device, 'gui_name', None) or _('Device')
if device.USER_CAN_ADD_NEW_FORMATS:
self.all_formats = set(self.all_formats) | set(BOOK_EXTENSIONS)
self.base = QWidget(self)
# self.insertTab(0, self.base, _('Configure %s') % self.device.current_friendly_name)
self.insertTab(0, self.base, _("File formats"))
l = self.base.l = QGridLayout(self.base)
self.base.setLayout(l)
self.formats = FormatsConfig(self.all_formats, device_settings.format_map)
if device.HIDE_FORMATS_CONFIG_BOX:
self.formats.hide()
self.opt_use_subdirs = create_checkbox(
_("Use sub-directories"),
_('Place files in sub-directories if the device supports them'),
device_settings.use_subdirs
)
self.opt_read_metadata = create_checkbox(
_("Read metadata from files on device"),
_('Read metadata from files on device'),
device_settings.read_metadata
)
self.template = TemplateConfig(device_settings.save_template)
self.opt_use_author_sort = create_checkbox(
_("Use author sort for author"),
_("Use author sort for author"),
device_settings.read_metadata
)
self.opt_use_author_sort.setObjectName("opt_use_author_sort")
self.base.la = la = QLabel(_(
'Choose the formats to send to the %s')%self.device_name)
la.setWordWrap(True)
l.addWidget(la, 1, 0, 1, 1)
l.addWidget(self.formats, 2, 0, 1, 1)
l.addWidget(self.opt_read_metadata, 3, 0, 1, 1)
l.addWidget(self.opt_use_subdirs, 4, 0, 1, 1)
l.addWidget(self.opt_use_author_sort, 5, 0, 1, 1)
l.addWidget(self.template, 6, 0, 1, 1)
l.setRowStretch(2, 10)
if device.HIDE_FORMATS_CONFIG_BOX:
self.formats.hide()
if supports_subdirs:
self.opt_use_subdirs.setChecked(device_settings.use_subdirs)
else:
self.opt_use_subdirs.hide()
if not must_read_metadata:
self.opt_read_metadata.setChecked(device_settings.read_metadata)
else:
self.opt_read_metadata.hide()
if supports_use_author_sort:
self.opt_use_author_sort.setChecked(device_settings.use_author_sort)
else:
self.opt_use_author_sort.hide()
self.extra_tab = ExtraCustomization(self.extra_customization_message,
self.extra_customization_choices,
self.device_settings)
# Only display the extra customization tab if there are options on it.
if self.extra_tab.has_extra_customizations:
self.addTab(self.extra_tab, _('Extra customization'))
self.setCurrentIndex(0)
示例15: __init__
def __init__(self, mi, fmt, opf, oeb, icon):
'''
:param mi: The book metadata
:param fmt: The source format used for conversion
:param opf: The path to the OPF file
:param oeb: An OEB object for the unpacked book
:param icon: The window icon
'''
self.opf = opf
self.oeb = oeb
self.mi = mi
# The unpacked book needs to be parsed before, to read the contents
# of the prince-style file, if it exists
self.parse()
QDialog.__init__(self)
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowTitle(_('Convert to PDF with Prince'))
self.setWindowIcon(icon)
self.l = QVBoxLayout()
self.setLayout(self.l)
self.title_label = QLabel(_('<b>Title:</b> %s') % self.mi.title)
self.l.addWidget(self.title_label)
self.format_label = QLabel(_('<b>Source format:</b> %s') % fmt)
self.l.addWidget(self.format_label)
self.add_book = QCheckBox(_('&Add PDF to the book record'))
self.add_book.setToolTip(_('<qt>Add the converted PDF to the selected book record</qt>'))
self.add_book.setChecked(prefs['add_book'])
self.add_book.stateChanged.connect(self.set_add_book)
self.l.addWidget(self.add_book)
self.ll = QHBoxLayout()
self.ll.setAlignment(Qt.AlignLeft)
self.l.addLayout(self.ll)
self.label_css = QLabel(_('&Custom style:'))
self.ll.addWidget(self.label_css)
self.css_list = QComboBox()
self.css_list.setToolTip(_('<qt>Select one style to use. Additional styles can be created in the plugin configuration</qt>'))
for key in sorted(prefs['custom_CSS_list'], key=lambda x: x.lower()):
self.css_list.addItem(key, key)
self.css_list.setCurrentIndex(self.css_list.findText(prefs['default_CSS']))
self.css_list.currentIndexChanged.connect(self.set_css)
self.ll.addWidget(self.css_list)
self.label_css.setBuddy(self.css_list)
self.ll_ = QHBoxLayout()
self.l.addLayout(self.ll_)
self.label_args = QLabel(_('A&dditional command-line arguments:'))
self.ll_.addWidget(self.label_args)
self.args = QLineEdit(self)
self.args.setText(prefs['custom_args_list'][prefs['default_CSS']])
self.args.setToolTip(_('<qt>Specify additional command-line arguments for the conversion</qt>'))
self.ll_.addWidget(self.args)
self.label_args.setBuddy(self.args)
self.css = QTabWidget()
self.l.addWidget(self.css)
self.css1 = TextEditWithTooltip(self, expected_geometry=(80,20))
self.css1.setLineWrapMode(TextEditWithTooltip.NoWrap)
self.css1.load_text(self.replace_templates(prefs['custom_CSS_list'][prefs['default_CSS']]),'css')
self.css1.setToolTip(_('<qt>This stylesheet can be modified<br/>The default can be configured</qt>'))
i = self.css.addTab(self.css1, _('C&ustom CSS'))
self.css.setTabToolTip(i, _('<qt>Custom CSS stylesheet to be used for this conversion</qt>'))
monofont = QFont('')
monofont.setStyleHint(QFont.TypeWriter)
if (self.prince_css):
self.css2 = QPlainTextEdit()
self.css2.setStyleSheet('* { font-family: monospace }')
self.css2.setLineWrapMode(QPlainTextEdit.NoWrap)
self.css2.setPlainText(self.prince_css)
self.css2.setReadOnly(True)
self.css2.setToolTip(_('<qt>This stylesheet cannot be modified</qt>'))
i = self.css.addTab(self.css2, _('&Book CSS'))
self.css.setTabToolTip(i, _('<qt>Book-specific CSS stylesheet included in the ebook file</qt>'))
self.ll = QHBoxLayout()
self.l.addLayout(self.ll)
if (prefs['show_CSS']):
self.toggle = QPushButton(self.hide_text, self)
else:
self.toggle = QPushButton(self.show_text, self)
self.toggle.setToolTip(_('<qt>Show/hide the additional styles used for the conversion</qt>'))
self.toggle.clicked.connect(self.toggle_tabs)
self.convert = QPushButton(_('Con&vert'), self)
self.convert.setToolTip(_('<qt>Run the conversion with Prince</qt>'))
#.........这里部分代码省略.........