本文整理汇总了Python中PyQt5.Qt.QScrollArea.setWidgetResizable方法的典型用法代码示例。如果您正苦于以下问题:Python QScrollArea.setWidgetResizable方法的具体用法?Python QScrollArea.setWidgetResizable怎么用?Python QScrollArea.setWidgetResizable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QScrollArea
的用法示例。
在下文中一共展示了QScrollArea.setWidgetResizable方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
def __init__(self, *args, **kw):
ConfigWidgetBase.__init__(self, *args, **kw)
self.l = l = QVBoxLayout(self)
l.setContentsMargins(0, 0, 0, 0)
self.tabs_widget = t = QTabWidget(self)
l.addWidget(t)
self.main_tab = m = MainTab(self)
t.addTab(m, _('&Main'))
m.start_server.connect(self.start_server)
m.stop_server.connect(self.stop_server)
m.test_server.connect(self.test_server)
m.show_logs.connect(self.view_server_logs)
self.opt_autolaunch_server = m.opt_autolaunch_server
self.users_tab = ua = Users(self)
t.addTab(ua, _('&User accounts'))
self.advanced_tab = a = AdvancedTab(self)
sa = QScrollArea(self)
sa.setWidget(a), sa.setWidgetResizable(True)
t.addTab(sa, _('&Advanced'))
self.custom_list_tab = clt = CustomList(self)
sa = QScrollArea(self)
sa.setWidget(clt), sa.setWidgetResizable(True)
t.addTab(sa, _('Book &list template'))
for tab in self.tabs:
if hasattr(tab, 'changed_signal'):
tab.changed_signal.connect(self.changed_signal.emit)
示例2: __init__
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
def __init__(self, parent_dialog, plugin_action):
self.parent_dialog = parent_dialog
self.plugin_action = plugin_action
QWidget.__init__(self)
self.l = QVBoxLayout()
self.setLayout(self.l)
label = QLabel(_("If you have custom columns defined, they will be listed below. Choose how you would like these columns handled."))
label.setWordWrap(True)
self.l.addWidget(label)
self.l.addSpacing(5)
scrollable = QScrollArea()
scrollcontent = QWidget()
scrollable.setWidget(scrollcontent)
scrollable.setWidgetResizable(True)
self.l.addWidget(scrollable)
self.sl = QVBoxLayout()
scrollcontent.setLayout(self.sl)
self.custcol_dropdowns = {}
custom_columns = self.plugin_action.gui.library_view.model().custom_columns
grid = QGridLayout()
self.sl.addLayout(grid)
row=0
for key, column in custom_columns.iteritems():
if column['datatype'] in permitted_values:
# print("\n============== %s ===========\n"%key)
# for (k,v) in column.iteritems():
# print("column['%s'] => %s"%(k,v))
label = QLabel('%s(%s)'%(column['name'],key))
label.setToolTip(_("Set this %s column on new merged books...")%column['datatype'])
grid.addWidget(label,row,0)
dropdown = QComboBox(self)
dropdown.addItem('','none')
for md in permitted_values[column['datatype']]:
# tags-like column also 'text'
if md == 'union' and not column['is_multiple']:
continue
if md == 'concat' and column['is_multiple']:
continue
dropdown.addItem(titleLabels[md],md)
self.custcol_dropdowns[key] = dropdown
if key in prefs['custom_cols']:
dropdown.setCurrentIndex(dropdown.findData(prefs['custom_cols'][key]))
dropdown.setToolTip(_("How this column will be populated by default."))
grid.addWidget(dropdown,row,1)
row+=1
self.sl.insertStretch(-1)
示例3: __init__
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
def __init__(self, parent_dialog, plugin_action):
QWidget.__init__(self)
self.parent_dialog = parent_dialog
self.plugin_action = plugin_action
self.l = QVBoxLayout()
self.setLayout(self.l)
label = QLabel(_('Searches to use for:'))
label.setWordWrap(True)
self.l.addWidget(label)
#self.l.addSpacing(5)
scrollable = QScrollArea()
scrollcontent = QWidget()
scrollable.setWidget(scrollcontent)
scrollable.setWidgetResizable(True)
self.l.addWidget(scrollable)
self.sl = QVBoxLayout()
scrollcontent.setLayout(self.sl)
self.sl.addWidget(QLabel(_("Search for Duplicated Books:")))
self.checkdups_search = QLineEdit(self)
self.sl.addWidget(self.checkdups_search)
self.checkdups_search.setText(prefs['checkdups_search'])
self.checkdups_search.setToolTip(_('Default is %s')%default_prefs['checkdups_search'])
self.sl.addSpacing(5)
self.sl.addWidget(QLabel(_("Deleted Books (not in Library):")))
self.checknotinlibrary_search = QLineEdit(self)
self.sl.addWidget(self.checknotinlibrary_search)
self.checknotinlibrary_search.setText(prefs['checknotinlibrary_search'])
self.checknotinlibrary_search.setToolTip(_('Default is %s')%default_prefs['checknotinlibrary_search'])
self.sl.addSpacing(5)
self.sl.addWidget(QLabel(_("Added Books (not on Device):")))
self.checknotondevice_search = QLineEdit(self)
self.sl.addWidget(self.checknotondevice_search)
self.checknotondevice_search.setText(prefs['checknotondevice_search'])
self.checknotondevice_search.setToolTip(_('Default is %s')%default_prefs['checknotondevice_search'])
self.sl.insertStretch(-1)
self.l.addSpacing(15)
restore_defaults_button = QPushButton(_('Restore Defaults'), self)
restore_defaults_button.setToolTip(_('Revert all searches to the defaults.'))
restore_defaults_button.clicked.connect(self.restore_defaults_button)
self.l.addWidget(restore_defaults_button)
示例4: get_notes_mail_widget
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
def get_notes_mail_widget(self):
"""
Return QWidget with notes and email areas and edition buttons
:return: notes and email QWidget
:rtype: QWidget
"""
notes_widget = QWidget()
notes_layout = QGridLayout(notes_widget)
# Notes title and button
notes_label = QLabel(_('Notes:'))
notes_label.setObjectName('subtitle')
notes_layout.addWidget(notes_label, 0, 0, 1, 1)
notes_btn = QPushButton()
notes_btn.setIcon(QIcon(settings.get_image('edit')))
notes_btn.setToolTip(_("Edit your notes."))
notes_btn.setFixedSize(32, 32)
notes_btn.clicked.connect(lambda: self.patch_data('notes'))
notes_layout.addWidget(notes_btn, 0, 2, 1, 1)
# Notes scroll area
self.labels['notes'].setText(data_manager.database['user'].data['notes'])
self.labels['notes'].setWordWrap(True)
self.labels['notes'].setTextInteractionFlags(Qt.TextSelectableByMouse)
notes_scrollarea = QScrollArea()
notes_scrollarea.setWidget(self.labels['notes'])
notes_scrollarea.setWidgetResizable(True)
notes_scrollarea.setObjectName('notes')
notes_layout.addWidget(notes_scrollarea, 1, 0, 1, 3)
# Mail
mail_label = QLabel(_('Email:'))
mail_label.setObjectName('subtitle')
notes_layout.addWidget(mail_label, 2, 0, 1, 1)
self.labels['email'].setObjectName('edit')
notes_layout.addWidget(self.labels['email'], 2, 1, 1, 1)
mail_btn = QPushButton()
mail_btn.setIcon(QIcon(settings.get_image('edit')))
mail_btn.setFixedSize(32, 32)
mail_btn.clicked.connect(lambda: self.patch_data('email'))
notes_layout.addWidget(mail_btn, 2, 2, 1, 1)
notes_layout.setAlignment(Qt.AlignTop)
return notes_widget
示例5: get_notes_output_widget
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
def get_notes_output_widget(self):
"""
Return QWidget with output and notes data
:return: widget with host output and notes
:rtype: QWidget
"""
widget = QWidget()
layout = QGridLayout()
widget.setLayout(layout)
# Output
output_title = QLabel(_("Output"))
output_title.setObjectName('title')
layout.addWidget(output_title, 0, 0, 1, 1)
self.labels['ls_output'].setWordWrap(True)
self.labels['ls_output'].setTextInteractionFlags(Qt.TextSelectableByMouse)
output_scrollarea = QScrollArea()
output_scrollarea.setWidget(self.labels['ls_output'])
output_scrollarea.setWidgetResizable(True)
output_scrollarea.setObjectName('output')
layout.addWidget(output_scrollarea, 1, 0, 1, 2)
# Notes
notes_title = QLabel(_("Notes:"))
notes_title.setObjectName('title')
layout.addWidget(notes_title, 0, 2, 1, 1)
notes_btn = QPushButton()
notes_btn.setIcon(QIcon(settings.get_image('edit')))
notes_btn.setToolTip(_("Edit host notes."))
notes_btn.setFixedSize(32, 32)
notes_btn.clicked.connect(self.patch_data)
layout.addWidget(notes_btn, 0, 3, 1, 1)
self.labels['notes'].setWordWrap(True)
self.labels['notes'].setTextInteractionFlags(Qt.TextSelectableByMouse)
notes_scrollarea = QScrollArea()
notes_scrollarea.setWidget(self.labels['notes'])
notes_scrollarea.setWidgetResizable(True)
notes_scrollarea.setObjectName('notes')
layout.addWidget(notes_scrollarea, 1, 2, 1, 2)
return widget
示例6: get_last_check_widget
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
def get_last_check_widget(self):
"""
Return QWidget with last check data
:return: widget with last check data
:rtype: QWidget
"""
widget = QWidget()
layout = QGridLayout()
widget.setLayout(layout)
# Title
check_title = QLabel(_('My last check'))
check_title.setObjectName('itemtitle')
check_title.setFixedHeight(30)
layout.addWidget(check_title, 0, 0, 1, 2)
# When last check
when_title = QLabel(_("When:"))
when_title.setObjectName('title')
layout.addWidget(when_title, 2, 0, 1, 1)
layout.addWidget(self.labels['ls_last_check'], 2, 1, 1, 1)
# Output
output_title = QLabel(_("Output"))
output_title.setObjectName('title')
layout.addWidget(output_title, 3, 0, 1, 1)
self.labels['ls_output'].setWordWrap(True)
self.labels['ls_output'].setTextInteractionFlags(Qt.TextSelectableByMouse)
output_scrollarea = QScrollArea()
output_scrollarea.setWidget(self.labels['ls_output'])
output_scrollarea.setWidgetResizable(True)
output_scrollarea.setObjectName('output')
layout.addWidget(output_scrollarea, 3, 1, 1, 1)
return widget
示例7: MetadataSingleDialogBase
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
class MetadataSingleDialogBase(ResizableDialog):
view_format = pyqtSignal(object, object)
cc_two_column = tweaks["metadata_single_use_2_cols_for_custom_fields"]
one_line_comments_toolbar = False
use_toolbutton_for_config_metadata = True
def __init__(self, db, parent=None):
self.db = db
self.changed = set()
self.books_to_refresh = set()
self.rows_to_refresh = set()
ResizableDialog.__init__(self, parent)
def setupUi(self, *args): # {{{
self.resize(990, 670)
self.download_shortcut = QShortcut(self)
self.download_shortcut.setKey(QKeySequence("Ctrl+D", QKeySequence.PortableText))
p = self.parent()
if hasattr(p, "keyboard"):
kname = "Interface Action: Edit Metadata (Edit Metadata) : menu action : download"
sc = p.keyboard.keys_map.get(kname, None)
if sc:
self.download_shortcut.setKey(sc[0])
self.button_box = bb = QDialogButtonBox(self)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
self.next_button = QPushButton(QIcon(I("forward.png")), _("Next"), self)
self.next_button.setShortcut(QKeySequence("Alt+Right"))
self.next_button.clicked.connect(self.next_clicked)
self.prev_button = QPushButton(QIcon(I("back.png")), _("Previous"), self)
self.prev_button.setShortcut(QKeySequence("Alt+Left"))
self.button_box.addButton(self.prev_button, bb.ActionRole)
self.button_box.addButton(self.next_button, bb.ActionRole)
self.prev_button.clicked.connect(self.prev_clicked)
bb.setStandardButtons(bb.Ok | bb.Cancel)
bb.button(bb.Ok).setDefault(True)
self.scroll_area = QScrollArea(self)
self.scroll_area.setFrameShape(QScrollArea.NoFrame)
self.scroll_area.setWidgetResizable(True)
self.central_widget = QTabWidget(self)
self.scroll_area.setWidget(self.central_widget)
self.l = QVBoxLayout(self)
self.setLayout(self.l)
self.l.addWidget(self.scroll_area)
ll = self.button_box_layout = QHBoxLayout()
self.l.addLayout(ll)
ll.addSpacing(10)
ll.addWidget(self.button_box)
self.setWindowIcon(QIcon(I("edit_input.png")))
self.setWindowTitle(BASE_TITLE)
self.create_basic_metadata_widgets()
if len(self.db.custom_column_label_map):
self.create_custom_metadata_widgets()
self.do_layout()
geom = gprefs.get("metasingle_window_geometry3", None)
if geom is not None:
self.restoreGeometry(bytes(geom))
# }}}
def create_basic_metadata_widgets(self): # {{{
self.basic_metadata_widgets = []
self.languages = LanguagesEdit(self)
self.basic_metadata_widgets.append(self.languages)
self.title = TitleEdit(self)
self.title.textChanged.connect(self.update_window_title)
self.deduce_title_sort_button = QToolButton(self)
self.deduce_title_sort_button.setToolTip(
_(
"Automatically create the title sort entry based on the current "
"title entry.\nUsing this button to create title sort will "
"change title sort from red to green."
)
)
self.deduce_title_sort_button.setWhatsThis(self.deduce_title_sort_button.toolTip())
self.title_sort = TitleSortEdit(self, self.title, self.deduce_title_sort_button, self.languages)
self.basic_metadata_widgets.extend([self.title, self.title_sort])
self.deduce_author_sort_button = b = QToolButton(self)
b.setToolTip(
"<p>"
+ _(
"Automatically create the author sort entry based on the current "
"author entry. Using this button to create author sort will "
"change author sort from red to green. There is a menu of "
"functions available under this button. Click and hold "
"on the button to see it."
)
#.........这里部分代码省略.........
示例8: do_layout
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
def do_layout(self):
self.central_widget.clear()
self.labels = []
sto = QWidget.setTabOrder
self.central_widget.tabBar().setVisible(False)
tab0 = QWidget(self)
self.central_widget.addTab(tab0, _("&Metadata"))
l = QGridLayout()
tab0.setLayout(l)
# Basic metadata in col 0
tl = QGridLayout()
gb = QGroupBox(_('Basic metadata'), tab0)
l.addWidget(gb, 0, 0, 1, 1)
gb.setLayout(tl)
self.button_box_layout.insertWidget(1, self.fetch_metadata_button)
self.button_box_layout.insertWidget(2, self.config_metadata_button)
sto(self.button_box, self.fetch_metadata_button)
sto(self.fetch_metadata_button, self.config_metadata_button)
sto(self.config_metadata_button, self.title)
def create_row(row, widget, tab_to, button=None, icon=None, span=1):
ql = BuddyLabel(widget)
tl.addWidget(ql, row, 1, 1, 1)
tl.addWidget(widget, row, 2, 1, 1)
if button is not None:
tl.addWidget(button, row, 3, span, 1)
if icon is not None:
button.setIcon(QIcon(I(icon)))
if tab_to is not None:
if button is not None:
sto(widget, button)
sto(button, tab_to)
else:
sto(widget, tab_to)
tl.addWidget(self.swap_title_author_button, 0, 0, 2, 1)
tl.addWidget(self.manage_authors_button, 2, 0, 2, 1)
tl.addWidget(self.paste_isbn_button, 12, 0, 1, 1)
tl.addWidget(self.tags_editor_button, 6, 0, 1, 1)
create_row(0, self.title, self.title_sort,
button=self.deduce_title_sort_button, span=2,
icon='auto_author_sort.png')
create_row(1, self.title_sort, self.authors)
create_row(2, self.authors, self.author_sort,
button=self.deduce_author_sort_button,
span=2, icon='auto_author_sort.png')
create_row(3, self.author_sort, self.series)
create_row(4, self.series, self.series_index,
button=self.clear_series_button, icon='trash.png')
create_row(5, self.series_index, self.tags)
create_row(6, self.tags, self.rating, button=self.clear_tags_button)
create_row(7, self.rating, self.pubdate, button=self.clear_ratings_button)
create_row(8, self.pubdate, self.publisher,
button=self.pubdate.clear_button, icon='trash.png')
create_row(9, self.publisher, self.languages,
button=self.publisher.clear_button, icon='trash.png')
create_row(10, self.languages, self.timestamp)
create_row(11, self.timestamp, self.identifiers,
button=self.timestamp.clear_button, icon='trash.png')
create_row(12, self.identifiers, self.comments,
button=self.clear_identifiers_button, icon='trash.png')
sto(self.clear_identifiers_button, self.swap_title_author_button)
sto(self.swap_title_author_button, self.manage_authors_button)
sto(self.manage_authors_button, self.tags_editor_button)
sto(self.tags_editor_button, self.paste_isbn_button)
tl.addItem(QSpacerItem(1, 1, QSizePolicy.Fixed, QSizePolicy.Expanding),
13, 1, 1 ,1)
# Custom metadata in col 1
w = getattr(self, 'custom_metadata_widgets_parent', None)
if w is not None:
gb = QGroupBox(_('Custom metadata'), tab0)
gbl = QVBoxLayout()
gb.setLayout(gbl)
sr = QScrollArea(gb)
sr.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
sr.setWidgetResizable(True)
sr.setFrameStyle(QFrame.NoFrame)
sr.setWidget(w)
gbl.addWidget(sr)
l.addWidget(gb, 0, 1, 1, 1)
sp = QSizePolicy()
sp.setVerticalStretch(10)
sp.setHorizontalPolicy(QSizePolicy.Minimum)
sp.setVerticalPolicy(QSizePolicy.Expanding)
gb.setSizePolicy(sp)
self.set_custom_metadata_tab_order()
# comments span col 0 & 1
w = QGroupBox(_('Comments'), tab0)
sp = QSizePolicy()
sp.setVerticalStretch(10)
sp.setHorizontalPolicy(QSizePolicy.Expanding)
sp.setVerticalPolicy(QSizePolicy.Expanding)
w.setSizePolicy(sp)
lb = QHBoxLayout()
#.........这里部分代码省略.........
示例9: MetadataSingleDialogBase
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
class MetadataSingleDialogBase(ResizableDialog):
view_format = pyqtSignal(object, object)
cc_two_column = tweaks['metadata_single_use_2_cols_for_custom_fields']
one_line_comments_toolbar = False
use_toolbutton_for_config_metadata = True
def __init__(self, db, parent=None, editing_multiple=False):
self.db = db
self.changed = set()
self.books_to_refresh = set()
self.rows_to_refresh = set()
self.metadata_before_fetch = None
self.editing_multiple = editing_multiple
self.comments_edit_state_at_apply = {}
ResizableDialog.__init__(self, parent)
def setupUi(self, *args): # {{{
self.resize(990, 670)
self.download_shortcut = QShortcut(self)
self.download_shortcut.setKey(QKeySequence('Ctrl+D',
QKeySequence.PortableText))
p = self.parent()
if hasattr(p, 'keyboard'):
kname = u'Interface Action: Edit Metadata (Edit Metadata) : menu action : download'
sc = p.keyboard.keys_map.get(kname, None)
if sc:
self.download_shortcut.setKey(sc[0])
self.swap_title_author_shortcut = s = QShortcut(self)
s.setKey(QKeySequence('Alt+Down', QKeySequence.PortableText))
self.button_box = bb = QDialogButtonBox(self)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
self.next_button = QPushButton(QIcon(I('forward.png')), _('Next'),
self)
self.next_button.setShortcut(QKeySequence('Alt+Right'))
self.next_button.clicked.connect(self.next_clicked)
self.prev_button = QPushButton(QIcon(I('back.png')), _('Previous'),
self)
self.prev_button.setShortcut(QKeySequence('Alt+Left'))
self.button_box.addButton(self.prev_button, bb.ActionRole)
self.button_box.addButton(self.next_button, bb.ActionRole)
self.prev_button.clicked.connect(self.prev_clicked)
bb.setStandardButtons(bb.Ok|bb.Cancel)
bb.button(bb.Ok).setDefault(True)
self.scroll_area = QScrollArea(self)
self.scroll_area.setFrameShape(QScrollArea.NoFrame)
self.scroll_area.setWidgetResizable(True)
self.central_widget = QTabWidget(self)
self.scroll_area.setWidget(self.central_widget)
self.l = QVBoxLayout(self)
self.setLayout(self.l)
self.l.addWidget(self.scroll_area)
ll = self.button_box_layout = QHBoxLayout()
self.l.addLayout(ll)
ll.addSpacing(10)
ll.addWidget(self.button_box)
self.setWindowIcon(QIcon(I('edit_input.png')))
self.setWindowTitle(BASE_TITLE)
self.create_basic_metadata_widgets()
if len(self.db.custom_column_label_map):
self.create_custom_metadata_widgets()
self.comments_edit_state_at_apply = {self.comments:None}
self.do_layout()
geom = gprefs.get('metasingle_window_geometry3', None)
if geom is not None:
self.restoreGeometry(bytes(geom))
# }}}
def create_basic_metadata_widgets(self): # {{{
self.basic_metadata_widgets = []
self.languages = LanguagesEdit(self)
self.basic_metadata_widgets.append(self.languages)
self.title = TitleEdit(self)
self.title.textChanged.connect(self.update_window_title)
self.deduce_title_sort_button = QToolButton(self)
self.deduce_title_sort_button.setToolTip(
_('Automatically create the title sort entry based on the current '
'title entry.\nUsing this button to create title sort will '
'change title sort from red to green.'))
self.deduce_title_sort_button.setWhatsThis(
self.deduce_title_sort_button.toolTip())
self.title_sort = TitleSortEdit(self, self.title,
self.deduce_title_sort_button, self.languages)
self.basic_metadata_widgets.extend([self.title, self.title_sort])
self.deduce_author_sort_button = b = RightClickButton(self)
b.setToolTip('<p>' +
_('Automatically create the author sort entry based on the current '
#.........这里部分代码省略.........
示例10: __init__
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
def __init__(self, parent_dialog, plugin_action):
QWidget.__init__(self)
self.parent_dialog = parent_dialog
self.plugin_action = plugin_action
self.l = QVBoxLayout()
self.setLayout(self.l)
self.editmetadata = QCheckBox(_('Edit Metadata for New Book(s)'),self)
self.editmetadata.setToolTip(_('Show Edit Metadata Dialog after creating each new book entry, but <i>before</i> EPUB is created.<br>Allows for downloading metadata and ensures EPUB has updated metadata.'))
self.editmetadata.setChecked(prefs['editmetadata'])
self.l.addWidget(self.editmetadata)
self.show_checkedalways = QCheckBox(_("Show 'Always Include' Checkboxes"),self)
self.show_checkedalways.setToolTip(_('If enabled, a checkbox will appear for each section.')+' '+
_('Checked sections will be included in <i>all</i> split books.<br>Default title will still be taken from the first <i>selected</i> section, and section order will remain as shown.'))
self.show_checkedalways.setChecked(prefs['show_checkedalways'])
self.l.addWidget(self.show_checkedalways)
self.l.addSpacing(5)
label = QLabel(_('When making a new Epub, the metadata from the source book will be copied or not as you choose below.'))
label.setWordWrap(True)
self.l.addWidget(label)
scrollable = QScrollArea()
scrollcontent = QWidget()
scrollable.setWidget(scrollcontent)
scrollable.setWidgetResizable(True)
self.l.addWidget(scrollable)
self.sl = QVBoxLayout()
scrollcontent.setLayout(self.sl)
self.copytoctitle = QCheckBox(_('Title from First Included TOC'),self)
self.copytoctitle.setToolTip(_('Copy Title from the the first Table of Contents entry included in the Split Epub.\nSupersedes Copy Title below.'))
self.copytoctitle.setChecked(prefs['copytoctitle'])
self.sl.addWidget(self.copytoctitle)
self.copytitle = QCheckBox(_('Copy Title'),self)
self.copytitle.setToolTip(_('Copy Title from the source Epub to the Split Epub. Adds "Split" to the title.'))
self.copytitle.setChecked(prefs['copytitle'])
self.sl.addWidget(self.copytitle)
self.copyauthors = QCheckBox(_('Copy Authors'),self)
self.copyauthors.setToolTip(_('Copy Authors from the source Epub to the Split Epub.'))
self.copyauthors.setChecked(prefs['copyauthors'])
self.sl.addWidget(self.copyauthors)
self.copyseries = QCheckBox(_('Copy Series'),self)
self.copyseries.setToolTip(_('Copy Series from the source Epub to the Split Epub.'))
self.copyseries.setChecked(prefs['copyseries'])
self.sl.addWidget(self.copyseries)
self.copycover = QCheckBox(_('Copy Cover'),self)
self.copycover.setToolTip(_('Copy Cover from the source Epub to the Split Epub.'))
self.copycover.setChecked(prefs['copycover'])
self.sl.addWidget(self.copycover)
self.copyrating = QCheckBox(_('Copy Rating'),self)
self.copyrating.setToolTip(_('Copy Rating from the source Epub to the Split Epub.'))
self.copyrating.setChecked(prefs['copyrating'])
self.sl.addWidget(self.copyrating)
self.copytags = QCheckBox(_('Copy Tags'),self)
self.copytags.setToolTip(_('Copy Tags from the source Epub to the Split Epub.'))
self.copytags.setChecked(prefs['copytags'])
self.sl.addWidget(self.copytags)
self.copyidentifiers = QCheckBox(_('Copy Identifiers'),self)
self.copyidentifiers.setToolTip(_('Copy Identifiers from the source Epub to the Split Epub.'))
self.copyidentifiers.setChecked(prefs['copyidentifiers'])
self.sl.addWidget(self.copyidentifiers)
self.copydate = QCheckBox(_('Copy Date'),self)
self.copydate.setToolTip(_('Copy Date from the source Epub to the Split Epub.'))
self.copydate.setChecked(prefs['copydate'])
self.sl.addWidget(self.copydate)
self.copypubdate = QCheckBox(_('Copy Published Date'),self)
self.copypubdate.setToolTip(_('Copy Published Date from the source Epub to the Split Epub.'))
self.copypubdate.setChecked(prefs['copypubdate'])
self.sl.addWidget(self.copypubdate)
self.copypublisher = QCheckBox(_('Copy Publisher'),self)
self.copypublisher.setToolTip(_('Copy Publisher from the source Epub to the Split Epub.'))
self.copypublisher.setChecked(prefs['copypublisher'])
self.sl.addWidget(self.copypublisher)
self.copylanguages = QCheckBox(_('Copy Languages'),self)
self.copylanguages.setToolTip(_('Copy Languages from the source Epub to the Split Epub.'))
self.copylanguages.setChecked(prefs['copylanguages'])
self.sl.addWidget(self.copylanguages)
self.copycomments = QCheckBox(_('Copy Comments'),self)
self.copycomments.setToolTip(_('Copy Comments from the source Epub to the Split Epub. Adds "Split from:" to the comments.'))
self.copycomments.setChecked(prefs['copycomments'])
self.sl.addWidget(self.copycomments)
self.sl.insertStretch(-1)
#.........这里部分代码省略.........
示例11: DemoDialog
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
class DemoDialog(QDialog):
def __init__(self, gui, icon, do_user_config):
QDialog.__init__(self, gui)
self.gui = gui
self.do_user_config = do_user_config
self.db = gui.current_db
self.l = QVBoxLayout()
self.setLayout(self.l)
self.setWindowTitle('Wiki Reader')
self.setWindowIcon(icon)
self.helpl = QLabel(
'Enter the URL of a wikipedia article below. '
'It will be downloaded and converted into an ebook.')
self.helpl.setWordWrap(True)
self.l.addWidget(self.helpl)
self.w = QWidget(self)
self.sa = QScrollArea(self)
self.l.addWidget(self.sa)
self.w.l = QVBoxLayout()
self.w.setLayout(self.w.l)
self.sa.setWidget(self.w)
self.sa.setWidgetResizable(True)
self.title = Title(self)
self.w.l.addWidget(self.title)
self.urls = [URL(self)]
self.w.l.addWidget(self.urls[0])
self.add_more_button = QPushButton(
QIcon(I('plus.png')), 'Add another URL')
self.l.addWidget(self.add_more_button)
self.bb = QDialogButtonBox(self)
self.bb.setStandardButtons(self.bb.Ok | self.bb.Cancel)
self.bb.accepted.connect(self.accept)
self.bb.rejected.connect(self.reject)
self.l.addWidget(self.bb)
self.book_button = b = self.bb.addButton(
'Convert a Wiki&Book', self.bb.ActionRole)
b.clicked.connect(self.wiki_book)
self.add_more_button.clicked.connect(self.add_more)
self.finished.connect(self.download)
self.setMinimumWidth(500)
self.resize(self.sizeHint())
self.single_url = None
def wiki_book(self):
d = QDialog(self)
d.l = l = QFormLayout(d)
l.setFieldGrowthPolicy(l.ExpandingFieldsGrow)
d.setWindowTitle('Enter WikiBook URL')
d.la = la = QLabel(
'<p>You can convert a pre-made WikiBook into a book here. '
'Simply enter the URL to the WikiBook page. For a list of '
'WikiBooks, see '
'<a href="https://en.wikipedia.org/wiki/Special:PrefixIndex/Book:'
'">here</a>.'
)
la.setMinimumWidth(400)
la.setWordWrap(True)
la.setOpenExternalLinks(True)
l.addRow(la)
d.le = le = QLineEdit(self)
l.addRow('WikiBook &URL:', le)
le.setText('https://')
le.selectAll()
d.bb = bb = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel, d)
l.addRow(bb)
bb.accepted.connect(d.accept), bb.rejected.connect(d.reject)
if d.exec_() == d.Accepted:
self.single_url = le.text()
self.accept()
def do_resize(self):
a = self.sizeHint()
b = self.w.sizeHint()
h = min(400, b.height())
self.resize(QSize(a.width(), h + 200))
def scroll_to_bottom(self):
v = self.sa.verticalScrollBar()
v.setValue(v.maximum())
def add_more(self):
url = URL(self)
self.urls.append(url)
self.w.l.addWidget(url)
QTimer.singleShot(0, self.do_resize)
QTimer.singleShot(10, self.scroll_to_bottom)
#.........这里部分代码省略.........
示例12: SearchTheInternet
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
class SearchTheInternet(QWidget):
changed_signal = pyqtSignal()
def __init__(self, parent):
QWidget.__init__(self, parent)
self.sa = QScrollArea(self)
self.lw = QWidget(self)
self.l = QVBoxLayout(self.lw)
self.sa.setWidget(self.lw), self.sa.setWidgetResizable(True)
self.gl = gl = QVBoxLayout(self)
self.la = QLabel(_(
'Add new locations to search for books or authors using the "Search the internet" feature'
' of the Content server. The URLs should contain {author} which will be'
' replaced by the author name and, for book URLs, {title} which will'
' be replaced by the book title.'))
self.la.setWordWrap(True)
gl.addWidget(self.la)
self.h = QHBoxLayout()
gl.addLayout(self.h)
self.add_url_button = b = QPushButton(QIcon(I('plus.png')), _('&Add URL'))
b.clicked.connect(self.add_url)
self.h.addWidget(b)
self.export_button = b = QPushButton(_('Export URLs'))
b.clicked.connect(self.export_urls)
self.h.addWidget(b)
self.import_button = b = QPushButton(_('Import URLs'))
b.clicked.connect(self.import_urls)
self.h.addWidget(b)
self.clear_button = b = QPushButton(_('Clear'))
b.clicked.connect(self.clear)
self.h.addWidget(b)
self.h.addStretch(10)
gl.addWidget(self.sa, stretch=10)
self.items = []
def genesis(self):
self.current_urls = search_the_net_urls() or []
@property
def current_urls(self):
return [item.as_dict for item in self.items if not item.is_empty]
def append_item(self, item_as_dict):
self.items.append(URLItem(item_as_dict, self))
self.l.addWidget(self.items[-1])
def clear(self):
[(self.l.removeWidget(w), w.setParent(None), w.deleteLater()) for w in self.items]
self.items = []
self.changed_signal.emit()
@current_urls.setter
def current_urls(self, val):
self.clear()
for entry in val:
self.append_item(entry)
def add_url(self):
self.items.append(URLItem(None, self))
self.l.addWidget(self.items[-1])
QTimer.singleShot(100, self.scroll_to_bottom)
def scroll_to_bottom(self):
sb = self.sa.verticalScrollBar()
if sb:
sb.setValue(sb.maximum())
self.items[-1].name_widget.setFocus(Qt.OtherFocusReason)
@property
def serialized_urls(self):
return json.dumps(self.current_urls, indent=2)
def commit(self):
for item in self.items:
if not item.validate():
return False
cu = self.current_urls
if cu:
with lopen(search_the_net_urls.path, 'wb') as f:
f.write(self.serialized_urls)
else:
try:
os.remove(search_the_net_urls.path)
except EnvironmentError as err:
if err.errno != errno.ENOENT:
raise
return True
def export_urls(self):
path = choose_save_file(
self, 'search-net-urls', _('Choose URLs file'),
filters=[(_('URL files'), ['json'])], initial_filename='search-urls.json')
if path:
with lopen(path, 'wb') as f:
f.write(self.serialized_urls)
def import_urls(self):
#.........这里部分代码省略.........
示例13: Preferences
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
class Preferences(QDialog):
run_wizard_requested = pyqtSignal()
def __init__(self, gui, initial_plugin=None, close_after_initial=False):
QDialog.__init__(self, gui)
self.gui = gui
self.must_restart = False
self.do_restart = False
self.committed = False
self.close_after_initial = close_after_initial
self.resize(930, 720)
nh, nw = min_available_height()-25, available_width()-10
if nh < 0:
nh = 800
if nw < 0:
nw = 600
nh = min(self.height(), nh)
nw = min(self.width(), nw)
self.resize(nw, nh)
geom = gprefs.get('preferences dialog geometry', None)
if geom is not None:
self.restoreGeometry(geom)
# Center
if islinux:
self.move(gui.rect().center() - self.rect().center())
self.setWindowModality(Qt.ApplicationModal)
self.setWindowTitle(__appname__ + ' - ' + _('Preferences'))
self.setWindowIcon(QIcon(I('config.png')))
self.l = l = QVBoxLayout(self)
self.stack = QStackedWidget(self)
self.bb = QDialogButtonBox(QDialogButtonBox.Close | QDialogButtonBox.Apply | QDialogButtonBox.Discard | QDialogButtonBox.RestoreDefaults)
self.bb.button(self.bb.Apply).clicked.connect(self.accept)
self.bb.button(self.bb.Discard).clicked.connect(self.reject)
self.bb.button(self.bb.RestoreDefaults).setIcon(QIcon(I('clear_left.png')))
self.bb.button(self.bb.RestoreDefaults).clicked.connect(self.restore_defaults)
self.wizard_button = self.bb.addButton(_('Run Welcome &wizard'), self.bb.ActionRole)
self.wizard_button.setIcon(QIcon(I('wizard.png')))
self.wizard_button.clicked.connect(self.run_wizard, type=Qt.QueuedConnection)
self.wizard_button.setAutoDefault(False)
self.bb.rejected.connect(self.reject)
self.browser = Browser(self)
self.browser.show_plugin.connect(self.show_plugin)
self.stack.addWidget(self.browser)
self.scroll_area = QScrollArea(self)
self.stack.addWidget(self.scroll_area)
self.scroll_area.setWidgetResizable(True)
self.setContextMenuPolicy(Qt.NoContextMenu)
self.title_bar = TitleBar(self)
for ac, tt in [(self.bb.Apply, _('Save changes')),
(self.bb.Discard, _('Cancel and return to overview'))]:
self.bb.button(ac).setToolTip(tt)
l.addWidget(self.title_bar), l.addWidget(self.stack), l.addWidget(self.bb)
if initial_plugin is not None:
category, name = initial_plugin[:2]
plugin = get_plugin(category, name)
if plugin is not None:
self.show_plugin(plugin)
if len(initial_plugin) > 2:
w = self.findChild(QWidget, initial_plugin[2])
if w is not None:
for c in self.showing_widget.children():
if isinstance(c, QTabWidget):
idx = c.indexOf(w)
if idx > -1:
c.setCurrentIndex(idx)
break
else:
self.hide_plugin()
def event(self, ev):
if isinstance(ev, QStatusTipEvent):
msg = re.sub(r'</?[a-z1-6]+>', ' ', ev.tip())
self.title_bar.show_msg(msg)
return QDialog.event(self, ev)
def run_wizard(self):
self.run_wizard_requested.emit()
self.accept()
def set_tooltips_for_labels(self):
def process_child(child):
for g in child.children():
if isinstance(g, QLabel):
buddy = g.buddy()
if buddy is not None and hasattr(buddy, 'toolTip'):
htext = unicode_type(buddy.toolTip()).strip()
etext = unicode_type(g.toolTip()).strip()
if htext and not etext:
g.setToolTip(htext)
g.setWhatsThis(htext)
#.........这里部分代码省略.........
示例14: Preferences
# 需要导入模块: from PyQt5.Qt import QScrollArea [as 别名]
# 或者: from PyQt5.Qt.QScrollArea import setWidgetResizable [as 别名]
class Preferences(QMainWindow):
run_wizard_requested = pyqtSignal()
def __init__(self, gui, initial_plugin=None, close_after_initial=False):
QMainWindow.__init__(self, gui)
self.gui = gui
self.must_restart = False
self.committed = False
self.close_after_initial = close_after_initial
self.resize(930, 720)
nh, nw = min_available_height()-25, available_width()-10
if nh < 0:
nh = 800
if nw < 0:
nw = 600
nh = min(self.height(), nh)
nw = min(self.width(), nw)
self.resize(nw, nh)
self.esc_action = QAction(self)
self.addAction(self.esc_action)
self.esc_action.setShortcut(QKeySequence(Qt.Key_Escape))
self.esc_action.triggered.connect(self.esc)
geom = gprefs.get('preferences_window_geometry', None)
if geom is not None:
self.restoreGeometry(geom)
# Center
if islinux:
self.move(gui.rect().center() - self.rect().center())
self.setWindowModality(Qt.WindowModal)
self.setWindowTitle(__appname__ + ' - ' + _('Preferences'))
self.setWindowIcon(QIcon(I('config.png')))
self.status_bar = StatusBar(self)
self.setStatusBar(self.status_bar)
self.stack = QStackedWidget(self)
self.cw = QWidget(self)
self.cw.setLayout(QVBoxLayout())
self.cw.layout().addWidget(self.stack)
self.bb = QDialogButtonBox(QDialogButtonBox.Close)
self.wizard_button = self.bb.addButton(_('Run welcome wizard'),
self.bb.ActionRole)
self.wizard_button.setIcon(QIcon(I('wizard.png')))
self.wizard_button.clicked.connect(self.run_wizard,
type=Qt.QueuedConnection)
self.cw.layout().addWidget(self.bb)
self.bb.button(self.bb.Close).setDefault(True)
self.bb.rejected.connect(self.close, type=Qt.QueuedConnection)
self.setCentralWidget(self.cw)
self.browser = Browser(self)
self.browser.show_plugin.connect(self.show_plugin)
self.stack.addWidget(self.browser)
self.scroll_area = QScrollArea(self)
self.stack.addWidget(self.scroll_area)
self.scroll_area.setWidgetResizable(True)
self.setContextMenuPolicy(Qt.NoContextMenu)
self.bar = QToolBar(self)
self.addToolBar(self.bar)
self.bar.setVisible(False)
self.bar.setIconSize(QSize(ICON_SIZE, ICON_SIZE))
self.bar.setMovable(False)
self.bar.setFloatable(False)
self.bar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.apply_action = self.bar.addAction(QIcon(I('ok.png')), _('&Apply'),
self.commit)
self.cancel_action = self.bar.addAction(QIcon(I('window-close.png')),
_('&Cancel'), self.cancel)
self.bar_title = BarTitle(self.bar)
self.bar.addWidget(self.bar_title)
self.restore_action = self.bar.addAction(QIcon(I('clear_left.png')),
_('Restore &defaults'), self.restore_defaults)
for ac, tt in [('apply', _('Save changes')),
('cancel', _('Cancel and return to overview'))]:
ac = getattr(self, ac+'_action')
ac.setToolTip(tt)
ac.setWhatsThis(tt)
ac.setStatusTip(tt)
for ch in self.bar.children():
if isinstance(ch, QToolButton):
ch.setCursor(Qt.PointingHandCursor)
ch.setAutoRaise(True)
self.stack.setCurrentIndex(0)
if initial_plugin is not None:
category, name = initial_plugin
plugin = get_plugin(category, name)
if plugin is not None:
self.show_plugin(plugin)
def run_wizard(self):
self.close()
self.run_wizard_requested.emit()
#.........这里部分代码省略.........