本文整理汇总了Python中PyQt5.Qt.QSplitter类的典型用法代码示例。如果您正苦于以下问题:Python QSplitter类的具体用法?Python QSplitter怎么用?Python QSplitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSplitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, books_view, parent=None):
QSplitter.__init__(self, parent)
self.setChildrenCollapsible(False)
self.books_view = books_view
self.addWidget(books_view)
self.addWidget(books_view.pin_view)
books_view.pin_view.splitter = self
示例2: __init__
def __init__(self, parent=None):
QSplitter.__init__(self, parent)
self.setChildrenCollapsible(False)
self.items = i = QListWidget(self)
i.setContextMenuPolicy(Qt.CustomContextMenu)
i.customContextMenuRequested.connect(self.context_menu)
self.items.setSpacing(3)
self.items.itemDoubleClicked.connect(self.current_item_activated)
self.items.currentItemChanged.connect(self.current_item_changed)
self.items.setSelectionMode(self.items.NoSelection)
self.delegate = Delegate(self.items)
self.items.setItemDelegate(self.delegate)
self.addWidget(i)
self.help = h = QTextBrowser(self)
h.anchorClicked.connect(self.link_clicked)
h.setOpenLinks(False)
self.addWidget(h)
self.setStretchFactor(0, 100)
self.setStretchFactor(1, 50)
self.clear_at_startup()
state = tprefs.get('check-book-splitter-state', None)
if state is not None:
self.restoreState(state)
示例3: __init__
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)
示例4: __init__
def __init__(self, name, label, icon, initial_show=True,
initial_side_size=120, connect_button=True,
orientation=Qt.Horizontal, side_index=0, parent=None, shortcut=None):
QSplitter.__init__(self, parent)
self.resize_timer = QTimer(self)
self.resize_timer.setSingleShot(True)
self.desired_side_size = initial_side_size
self.desired_show = initial_show
self.resize_timer.setInterval(5)
self.resize_timer.timeout.connect(self.do_resize)
self.setOrientation(orientation)
self.side_index = side_index
self._name = name
self.label = label
self.initial_side_size = initial_side_size
self.initial_show = initial_show
self.splitterMoved.connect(self.splitter_moved, type=Qt.QueuedConnection)
self.button = LayoutButton(icon, label, self, shortcut=shortcut)
if connect_button:
self.button.clicked.connect(self.double_clicked)
if shortcut is not None:
self.action_toggle = QAction(QIcon(icon), _('Toggle') + ' ' + label,
self)
self.action_toggle.triggered.connect(self.toggle_triggered)
if parent is not None:
parent.addAction(self.action_toggle)
if hasattr(parent, 'keyboard'):
parent.keyboard.register_shortcut('splitter %s %s'%(name,
label), unicode(self.action_toggle.text()),
default_keys=(shortcut,), action=self.action_toggle)
else:
self.action_toggle.setShortcut(shortcut)
else:
self.action_toggle.setShortcut(shortcut)
示例5: __init__
def __init__(self, parent=None, show_open_in_editor=False):
QSplitter.__init__(self, parent)
self._failed_img = None
self.left, self.right = TextBrowser(parent=self), TextBrowser(right=True, parent=self, show_open_in_editor=show_open_in_editor)
self.addWidget(self.left), self.addWidget(self.right)
self.split_words = re.compile(r"\w+|\W", re.UNICODE)
self.clear()
示例6: do_resize
def do_resize(self, *args):
orig = self.desired_side_size
QSplitter.resizeEvent(self, self._resize_ev)
if orig > 20 and self.desired_show:
c = 0
while abs(self.side_index_size - orig) > 10 and c < 5:
self.apply_state(self.get_state(), save_desired=False)
c += 1
示例7: setup_ui
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)
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.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()
示例8: __init__
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)
示例9: Snipdom
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
示例10: setup_ui
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()
示例11: ThemeCreateDialog
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)
示例12: __init__
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)
示例13: CheckLibraryDialog
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)
#.........这里部分代码省略.........
示例14: resizeEvent
def resizeEvent(self, ev):
self.frame_resized.emit(ev)
return QSplitter.resizeEvent(self, ev)
示例15: BookInfo
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):
#.........这里部分代码省略.........