本文整理汇总了Python中PyQt5.Qt.QSplitter.addWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.addWidget方法的具体用法?Python QSplitter.addWidget怎么用?Python QSplitter.addWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QSplitter
的用法示例。
在下文中一共展示了QSplitter.addWidget方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.Qt import QSplitter [as 别名]
# 或者: from PyQt5.Qt.QSplitter import addWidget [as 别名]
def __init__(self, controller):
super().__init__()
self.controller = controller
self.setWindowTitle(controller.title())
self.win_editor = EditWindow()
splitter = QSplitter()
splitter.addWidget(SideWindow())
splitter.addWidget(self.win_editor)
self.setGeometry(100, 100, 500, 355)
self.setCentralWidget(splitter)
self.statusBar().setSizeGripEnabled(True)
init_file_toolbar(self)
init_edit_toolbar(self)
init_menu(self)
示例2: Snipdom
# 需要导入模块: from PyQt5.Qt import QSplitter [as 别名]
# 或者: from PyQt5.Qt.QSplitter import addWidget [as 别名]
class Snipdom(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.hsplit = QSplitter()
self.setCentralWidget(self.hsplit)
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
self.kernel = kernel_manager.kernel
self.kernel.gui = 'qt'
self.control = RichIPythonWidget(gui_completion="droplist")
self.kernel.shell.push({'snipdom': self})
kernel_client = kernel_manager.client()
kernel_client.start_channels()
self.control.kernel_manager = kernel_manager
self.control.kernel_client = kernel_client
self.vsplit = QSplitter()
self.vsplit.setOrientation(Qt.Vertical)
self.vsplit.addWidget(self.control)
self.hsplit.addWidget(self.vsplit)
self.sendButton = QPushButton("send")
#self.sendButton.clicked.connect(self.sendcode)
self.vsplit.addWidget(self.sendButton)
self.bridge = Js2Py()
self.bridge.sent.connect(self.codeFromJs)
#lab = QtGui.QLabel(kernel.shell.history_manager.get_range(start=-1).next()[2])
def codeFromJs(self, code):
self.control.input_buffer = code
示例3: CheckLibraryDialog
# 需要导入模块: from PyQt5.Qt import QSplitter [as 别名]
# 或者: from PyQt5.Qt.QSplitter import addWidget [as 别名]
class CheckLibraryDialog(QDialog):
def __init__(self, parent, db):
QDialog.__init__(self, parent)
self.db = db
self.setWindowTitle(_('Check Library -- Problems Found'))
self.setWindowIcon(QIcon(I('debug.png')))
self._tl = QHBoxLayout()
self.setLayout(self._tl)
self.splitter = QSplitter(self)
self.left = QWidget(self)
self.splitter.addWidget(self.left)
self.helpw = QTextEdit(self)
self.splitter.addWidget(self.helpw)
self._tl.addWidget(self.splitter)
self._layout = QVBoxLayout()
self.left.setLayout(self._layout)
self.helpw.setReadOnly(True)
self.helpw.setText(_('''\
<h1>Help</h1>
<p>calibre stores the list of your books and their metadata in a
database. The actual book files and covers are stored as normal
files in the calibre library folder. The database contains a list of the files
and covers belonging to each book entry. This tool checks that the
actual files in the library folder on your computer match the
information in the database.</p>
<p>The result of each type of check is shown to the left. The various
checks are:
</p>
<ul>
<li><b>Invalid titles</b>: These are files and folders appearing
in the library where books titles should, but that do not have the
correct form to be a book title.</li>
<li><b>Extra titles</b>: These are extra files in your calibre
library that appear to be correctly-formed titles, but have no corresponding
entries in the database</li>
<li><b>Invalid authors</b>: These are files appearing
in the library where only author folders should be.</li>
<li><b>Extra authors</b>: These are folders in the
calibre library that appear to be authors but that do not have entries
in the database</li>
<li><b>Missing book formats</b>: These are book formats that are in
the database but have no corresponding format file in the book's folder.
<li><b>Extra book formats</b>: These are book format files found in
the book's folder but not in the database.
<li><b>Unknown files in books</b>: These are extra files in the
folder of each book that do not correspond to a known format or cover
file.</li>
<li><b>Missing cover files</b>: These represent books that are marked
in the database as having covers but the actual cover files are
missing.</li>
<li><b>Cover files not in database</b>: These are books that have
cover files but are marked as not having covers in the database.</li>
<li><b>Folder raising exception</b>: These represent folders in the
calibre library that could not be processed/understood by this
tool.</li>
</ul>
<p>There are two kinds of automatic fixes possible: <i>Delete
marked</i> and <i>Fix marked</i>.</p>
<p><i>Delete marked</i> is used to remove extra files/folders/covers that
have no entries in the database. Check the box next to the item you want
to delete. Use with caution.</p>
<p><i>Fix marked</i> is applicable only to covers and missing formats
(the three lines marked 'fixable'). In the case of missing cover files,
checking the fixable box and pushing this button will tell calibre that
there is no cover for all of the books listed. Use this option if you
are not going to restore the covers from a backup. In the case of extra
cover files, checking the fixable box and pushing this button will tell
calibre that the cover files it found are correct for all the books
listed. Use this when you are not going to delete the file(s). In the
case of missing formats, checking the fixable box and pushing this
button will tell calibre that the formats are really gone. Use this if
you are not going to restore the formats from a backup.</p>
'''))
self.log = QTreeWidget(self)
self.log.itemChanged.connect(self.item_changed)
self.log.itemExpanded.connect(self.item_expanded_or_collapsed)
self.log.itemCollapsed.connect(self.item_expanded_or_collapsed)
self._layout.addWidget(self.log)
self.check_button = QPushButton(_('&Run the check again'))
self.check_button.setDefault(False)
self.check_button.clicked.connect(self.run_the_check)
self.copy_button = QPushButton(_('Copy &to clipboard'))
self.copy_button.setDefault(False)
self.copy_button.clicked.connect(self.copy_to_clipboard)
self.ok_button = QPushButton(_('&Done'))
self.ok_button.setDefault(True)
self.ok_button.clicked.connect(self.accept)
self.mark_delete_button = QPushButton(_('Mark &all for delete'))
self.mark_delete_button.setToolTip(_('Mark all deletable subitems'))
self.mark_delete_button.setDefault(False)
#.........这里部分代码省略.........
示例4: MetadataSingleDialogAlt1
# 需要导入模块: from PyQt5.Qt import QSplitter [as 别名]
# 或者: from PyQt5.Qt.QSplitter import addWidget [as 别名]
class MetadataSingleDialogAlt1(MetadataSingleDialogBase): # {{{
cc_two_column = False
one_line_comments_toolbar = True
use_toolbutton_for_config_metadata = False
on_drag_enter = pyqtSignal()
def handle_drag_enter(self):
self.central_widget.setCurrentIndex(1)
def do_layout(self):
self.central_widget.clear()
self.tabs = []
self.labels = []
sto = QWidget.setTabOrder
self.on_drag_enter.connect(self.handle_drag_enter)
self.tabs.append(DragTrackingWidget(self, self.on_drag_enter))
self.central_widget.addTab(self.tabs[0], _("&Metadata"))
self.tabs[0].l = QGridLayout()
self.tabs[0].setLayout(self.tabs[0].l)
self.tabs.append(QWidget(self))
self.central_widget.addTab(self.tabs[1], _("&Cover and formats"))
self.tabs[1].l = QGridLayout()
self.tabs[1].setLayout(self.tabs[1].l)
# accept drop events so we can automatically switch to the second tab to
# drop covers and formats
self.tabs[0].setAcceptDrops(True)
# Tab 0
tab0 = self.tabs[0]
tl = QGridLayout()
gb = QGroupBox(_('&Basic metadata'), self.tabs[0])
self.tabs[0].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, 1, 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)
w = getattr(self, 'custom_metadata_widgets_parent', None)
if w is not None:
gb = QGroupBox(_('C&ustom metadata'), tab0)
gbl = QVBoxLayout()
gb.setLayout(gbl)
sr = QScrollArea(tab0)
#.........这里部分代码省略.........
示例5: BookInfo
# 需要导入模块: from PyQt5.Qt import QSplitter [as 别名]
# 或者: from PyQt5.Qt.QSplitter import addWidget [as 别名]
class BookInfo(QDialog):
closed = pyqtSignal(object)
def __init__(self, parent, view, row, link_delegate):
QDialog.__init__(self, parent)
self.normal_brush = QBrush(Qt.white)
self.marked_brush = QBrush(Qt.lightGray)
self.marked = None
self.gui = parent
self.splitter = QSplitter(self)
self._l = l = QVBoxLayout(self)
self.setLayout(l)
l.addWidget(self.splitter)
self.cover = CoverView(self)
self.cover.resizeEvent = self.cover_view_resized
self.cover.cover_changed.connect(self.cover_changed)
self.cover_pixmap = None
self.cover.sizeHint = self.details_size_hint
self.splitter.addWidget(self.cover)
self.details = Details(parent.book_details.book_info, self)
self.details.page().setLinkDelegationPolicy(self.details.page().DelegateAllLinks)
self.details.linkClicked.connect(self.link_clicked)
s = self.details.page().settings()
s.setAttribute(s.JavascriptEnabled, False)
self.css = css()
self.link_delegate = link_delegate
self.details.setAttribute(Qt.WA_OpaquePaintEvent, False)
palette = self.details.palette()
self.details.setAcceptDrops(False)
palette.setBrush(QPalette.Base, Qt.transparent)
self.details.page().setPalette(palette)
self.c = QWidget(self)
self.c.l = l2 = QGridLayout(self.c)
self.c.setLayout(l2)
l2.addWidget(self.details, 0, 0, 1, -1)
self.splitter.addWidget(self.c)
self.fit_cover = QCheckBox(_('Fit &cover within view'), self)
self.fit_cover.setChecked(gprefs.get('book_info_dialog_fit_cover', True))
l2.addWidget(self.fit_cover, l2.rowCount(), 0, 1, -1)
self.previous_button = QPushButton(QIcon(I('previous.png')), _('&Previous'), self)
self.previous_button.clicked.connect(self.previous)
l2.addWidget(self.previous_button, l2.rowCount(), 0)
self.next_button = QPushButton(QIcon(I('next.png')), _('&Next'), self)
self.next_button.clicked.connect(self.next)
l2.addWidget(self.next_button, l2.rowCount() - 1, 1)
self.view = view
self.current_row = None
self.refresh(row)
self.view.model().new_bookdisplay_data.connect(self.slave)
self.fit_cover.stateChanged.connect(self.toggle_cover_fit)
self.ns = QShortcut(QKeySequence('Alt+Right'), self)
self.ns.activated.connect(self.next)
self.ps = QShortcut(QKeySequence('Alt+Left'), self)
self.ps.activated.connect(self.previous)
self.next_button.setToolTip(_('Next [%s]')%
unicode(self.ns.key().toString(QKeySequence.NativeText)))
self.previous_button.setToolTip(_('Previous [%s]')%
unicode(self.ps.key().toString(QKeySequence.NativeText)))
geom = QCoreApplication.instance().desktop().availableGeometry(self)
screen_height = geom.height() - 100
screen_width = geom.width() - 100
self.resize(max(int(screen_width/2), 700), screen_height)
saved_layout = gprefs.get('book_info_dialog_layout', None)
if saved_layout is not None:
try:
self.restoreGeometry(saved_layout[0])
self.splitter.restoreState(saved_layout[1])
except Exception:
pass
def link_clicked(self, qurl):
link = unicode(qurl.toString(NO_URL_FORMATTING))
self.link_delegate(link)
def done(self, r):
saved_layout = (bytearray(self.saveGeometry()), bytearray(self.splitter.saveState()))
gprefs.set('book_info_dialog_layout', saved_layout)
ret = QDialog.done(self, r)
self.view.model().new_bookdisplay_data.disconnect(self.slave)
self.view = self.link_delegate = self.gui = None
self.closed.emit(self)
return ret
def cover_changed(self, data):
if self.current_row is not None:
id_ = self.view.model().id(self.current_row)
self.view.model().db.set_cover(id_, data)
self.gui.refresh_cover_browser()
ci = self.view.currentIndex()
if ci.isValid():
self.view.model().current_changed(ci, ci)
def details_size_hint(self):
#.........这里部分代码省略.........
示例6: ThemeCreateDialog
# 需要导入模块: from PyQt5.Qt import QSplitter [as 别名]
# 或者: from PyQt5.Qt.QSplitter import addWidget [as 别名]
class ThemeCreateDialog(Dialog):
def __init__(self, parent, report):
self.report = report
Dialog.__init__(self, _('Create an icon theme'), 'create-icon-theme', parent)
def setup_ui(self):
self.splitter = QSplitter(self)
self.l = l = QVBoxLayout(self)
l.addWidget(self.splitter)
l.addWidget(self.bb)
self.w = w = QGroupBox(_('Theme Metadata'), self)
self.splitter.addWidget(w)
l = w.l = QFormLayout(w)
l.setFieldGrowthPolicy(l.ExpandingFieldsGrow)
self.missing_icons_group = mg = QGroupBox(self)
self.mising_icons = mi = QListWidget(mg)
mi.setSelectionMode(mi.NoSelection)
mg.l = QVBoxLayout(mg)
mg.l.addWidget(mi)
self.splitter.addWidget(mg)
self.title = QLineEdit(self)
l.addRow(_('&Title:'), self.title)
self.author = QLineEdit(self)
l.addRow(_('&Author:'), self.author)
self.version = v = QSpinBox(self)
v.setMinimum(1), v.setMaximum(1000000)
l.addRow(_('&Version:'), v)
self.license = lc = QLineEdit(self)
l.addRow(_('&License:'), lc)
self.url = QLineEdit(self)
l.addRow(_('&URL:'), self.url)
lc.setText(_(
'The license for the icons in this theme. Common choices are'
' Creative Commons or Public Domain.'))
self.description = QTextEdit(self)
l.addRow(self.description)
self.refresh_button = rb = self.bb.addButton(_('&Refresh'), self.bb.ActionRole)
rb.setIcon(QIcon(I('view-refresh.png')))
rb.clicked.connect(self.refresh)
self.apply_report()
def sizeHint(self):
return QSize(900, 670)
@property
def metadata(self):
self.report.theme.title = self.title.text().strip() # Needed for report.name to work
return {
'title': self.title.text().strip(),
'author': self.author.text().strip(),
'version': self.version.value(),
'description': self.description.toPlainText().strip(),
'number': len(self.report.name_map) - len(self.report.extra),
'date': utcnow().date().isoformat(),
'name': self.report.name,
'license': self.license.text().strip() or 'Unknown',
'url': self.url.text().strip() or None,
}
def save_metadata(self):
with open(os.path.join(self.report.path, THEME_METADATA), 'wb') as f:
json.dump(self.metadata, f, indent=2)
def refresh(self):
self.save_metadata()
self.report = read_theme_from_folder(self.report.path)
self.apply_report()
def apply_report(self):
theme = self.report.theme
self.title.setText((theme.title or '').strip())
self.author.setText((theme.author or '').strip())
self.version.setValue(theme.version or 1)
self.description.setText((theme.description or '').strip())
self.license.setText((theme.license or 'Unknown').strip())
self.url.setText((theme.url or '').strip())
if self.report.missing:
title = _('%d icons missing in this theme') % len(self.report.missing)
else:
title = _('No missing icons')
self.missing_icons_group.setTitle(title)
mi = self.mising_icons
mi.clear()
for name in sorted(self.report.missing):
QListWidgetItem(QIcon(I(name, allow_user_override=False)), name, mi)
def accept(self):
mi = self.metadata
if not mi.get('title'):
return error_dialog(self, _('No title specified'), _(
'You must specify a title for this icon theme'), show=True)
if not mi.get('author'):
return error_dialog(self, _('No author specified'), _(
'You must specify an author for this icon theme'), show=True)
return Dialog.accept(self)
示例7: MainWin
# 需要导入模块: from PyQt5.Qt import QSplitter [as 别名]
# 或者: from PyQt5.Qt.QSplitter import addWidget [as 别名]
class MainWin(QMainWindow):
def __init__(self, fileName=None, logName=None, parent=None):
super(MainWin, self).__init__(parent)
#self.setWindowIcon(QIcon(':/images/logo.png'))
self.setToolButtonStyle(Qt.ToolButtonFollowStyle)
self.setupFileActions()
self.setupEditActions()
self.setupTextActions()
self.setupRunActions()
self.initializeSettings()
self.populateRunSettings() # FIXME put in initializeSettings()?
settingsMenu = QMenu('Settings', self)
self.menuBar().addMenu(settingsMenu)
settingsMenu.addAction('Configure...', self.configure)
helpMenu = QMenu("Help", self)
self.menuBar().addMenu(helpMenu)
helpMenu.addAction("About", self.about)
helpMenu.addAction("About &Qt", QApplication.instance().aboutQt)
self.splitter = QSplitter(self)
self.splitter.setOrientation(Qt.Vertical)
self.textPane = TextPane()
self.logPane = LogPane()
self.logBox = QGroupBox()
self.logBox.setFlat(True)
vbox = QVBoxLayout()
vbox.addWidget(self.logPane)
self.logBox.setLayout(vbox)
self.splitter.addWidget(self.textPane)
self.splitter.addWidget(QLabel()) # spacer
self.splitter.addWidget(self.logBox)
self.setCentralWidget(self.splitter)
self.loadSrc(fileName)
self.loadLog(logName)
#if logName and (-1 == self.comboLogFile.findText(logName)):
#self.comboLogFile.addItem(logName)
self.logPane.setFocus()
self.fontChanged(self.textPane.font())
self.textPane.document().modificationChanged.connect(self.actionSave.setEnabled)
self.textPane.document().modificationChanged.connect(self.setWindowModified)
self.textPane.document().undoAvailable.connect(self.actionUndo.setEnabled)
self.textPane.document().redoAvailable.connect( self.actionRedo.setEnabled)
self.setWindowModified(self.textPane.document().isModified())
self.actionSave.setEnabled(self.textPane.document().isModified())
self.actionUndo.setEnabled(self.textPane.document().isUndoAvailable())
self.actionRedo.setEnabled(self.textPane.document().isRedoAvailable())
self.actionUndo.triggered.connect(self.textPane.undo)
self.actionRedo.triggered.connect(self.textPane.redo)
self.actionCut.setEnabled(False)
self.actionCopy.setEnabled(False)
self.actionCut.triggered.connect(self.textPane.cut)
self.actionCopy.triggered.connect(self.textPane.copy)
self.actionPaste.triggered.connect(self.textPane.paste)
self.textPane.copyAvailable.connect(self.actionCut.setEnabled)
self.textPane.copyAvailable.connect(self.actionCopy.setEnabled)
QApplication.clipboard().dataChanged.connect(self.clipboardDataChanged)
self.actionRun.triggered.connect(self.scannoCheck)
self.logPane.lineMatchChanged.connect(self.logLineMatchChanged)
def closeEvent(self, e):
if self.maybeSave():
e.accept()
else:
e.ignore()
def setupFileActions(self):
tb = QToolBar(self)
tb.setWindowTitle("File Actions")
self.addToolBar(tb)
menu = QMenu("&File", self)
self.menuBar().addMenu(menu)
self.actionNew = QAction("&New", self, priority=QAction.LowPriority,
shortcut=QKeySequence.New, triggered=self.fileNew)
tb.addAction(self.actionNew)
menu.addAction(self.actionNew)
self.actionOpen = QAction("&Open...", self, shortcut=QKeySequence.Open,
triggered=self.fileOpen)
tb.addAction(self.actionOpen)
menu.addAction(self.actionOpen)
menu.addSeparator()
self.actionSave = QAction("&Save", self, shortcut=QKeySequence.Save,
triggered=self.fileSave, enabled=False)
tb.addAction(self.actionSave)
menu.addAction(self.actionSave)
self.actionSaveAs = QAction("Save &As...", self, priority=QAction.LowPriority,
shortcut=Qt.CTRL + Qt.SHIFT + Qt.Key_S, triggered=self.fileSaveAs)
menu.addAction(self.actionSaveAs)
menu.addSeparator()
#.........这里部分代码省略.........