本文整理汇总了Python中PyQt5.QtWidgets.QSplitter.width方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.width方法的具体用法?Python QSplitter.width怎么用?Python QSplitter.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QSplitter
的用法示例。
在下文中一共展示了QSplitter.width方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DatabaseContainer
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import width [as 别名]
#.........这里部分代码省略.........
def __on_data_table_changed(self, row, col, data):
current_relation = self.lateral_widget.current_text()
# Relation to be update
rela = self.table_widget.relations.get(current_relation)
# Clear old content
rela.clear()
current_table = self.table_widget.stacked.currentWidget()
model = current_table.model()
for i in range(model.rowCount()):
reg = []
for j in range(model.columnCount()):
if row == i and col == j:
reg.append(data)
else:
reg.append(model.item(i, j).text())
# Insert new content
rela.insert(reg)
# Update relation
self.table_widget.relations[current_relation] = rela
def new_query(self, filename):
editor_tab_at = self.query_container.is_open(filename)
if editor_tab_at != -1:
self.query_container.set_focus_editor_tab(editor_tab_at)
else:
query_widget = query_container.QueryWidget()
# Create object file
ffile = pfile.File(filename)
editor = query_widget.get_editor()
editor.pfile = ffile
if not filename:
ffile.filename = 'untitled_{n}.pqf'.format(n=self.__nquery)
else:
content = ffile.read()
editor.setPlainText(content)
self.query_container.add_tab(query_widget, ffile.display_name)
self.__nquery += 1
def save_query(self, editor):
if not editor:
editor = self.query_container.currentWidget().get_editor()
if editor.is_new:
return self.save_query_as(editor)
# Get content of editor
content = editor.toPlainText()
try:
editor.pfile.save(content=content)
except Exception as reason:
QMessageBox.critical(self, "Error",
self.tr("The file couldn't be saved!"
"\n\n{}".format(reason)))
return False
editor.saved()
return editor.pfile.filename
def save_query_as(self, editor=None):
filename = QFileDialog.getSaveFileName(self, self.tr("Save File"),
editor.name,
"Pireal query files(*.pqf)")
filename = filename[0]
if not filename:
return
# Get the content
content = editor.toPlainText()
# Write the file
editor.pfile.save(content=content, new_fname=filename)
editor.saved()
def execute_queries(self):
self.query_container.execute_queries()
def execute_selection(self):
editor = self.query_container.currentWidget().get_editor()
text_cursor = editor.textCursor()
if text_cursor.hasSelection():
query = text_cursor.selectedText()
self.query_container.execute_queries(query)
def showEvent(self, event):
QSplitter.showEvent(self, event)
qsettings = QSettings(settings.SETTINGS_PATH, QSettings.IniFormat)
hsizes = qsettings.value('hsplitter_sizes', None)
if hsizes is not None:
self._hsplitter.restoreState(hsizes)
else:
self._hsplitter.setSizes([1, self._hsplitter.width() / 3])
vsizes = qsettings.value('vsplitter_sizes', None)
if vsizes is not None:
self.restoreState(vsizes)
else:
self.setSizes([self.height() / 3, self.height() / 3])
def save_sizes(self):
""" Save sizes of Splitters """
qsettings = QSettings(settings.SETTINGS_PATH, QSettings.IniFormat)
qsettings.setValue('hsplitter_sizes',
self._hsplitter.saveState())
qsettings.setValue('vsplitter_sizes',
self.saveState())
示例2: Listspace
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import width [as 别名]
class Listspace(QSplitter, ViewManager):
"""
Class implementing the listspace viewmanager class.
@signal changeCaption(str) emitted if a change of the caption is necessary
@signal editorChanged(str) emitted when the current editor has changed
@signal editorChangedEd(Editor) emitted when the current editor has changed
@signal lastEditorClosed() emitted after the last editor window was closed
@signal editorOpened(str) emitted after an editor window was opened
@signal editorOpenedEd(Editor) emitted after an editor window was opened
@signal editorClosed(str) emitted just before an editor window gets closed
@signal editorClosedEd(Editor) emitted just before an editor window gets
closed
@signal editorRenamed(str) emitted after an editor was renamed
@signal editorRenamedEd(Editor) emitted after an editor was renamed
@signal editorSaved(str) emitted after an editor window was saved
@signal editorSavedEd(Editor) emitted after an editor window was saved
@signal checkActions(Editor) emitted when some actions should be checked
for their status
@signal cursorChanged(Editor) emitted after the cursor position of the
active window has changed
@signal breakpointToggled(Editor) emitted when a breakpoint is toggled.
@signal bookmarkToggled(Editor) emitted when a bookmark is toggled.
@signal syntaxerrorToggled(Editor) emitted when a syntax error is toggled.
@signal previewStateChanged(bool) emitted to signal a change in the
preview state
@signal editorLanguageChanged(Editor) emitted to signal a change of an
editors language
@signal editorTextChanged(Editor) emitted to signal a change of an
editor's text
@signal editorLineChanged(str,int) emitted to signal a change of an
editor's current line (line is given one based)
"""
changeCaption = pyqtSignal(str)
editorChanged = pyqtSignal(str)
editorChangedEd = pyqtSignal(Editor)
lastEditorClosed = pyqtSignal()
editorOpened = pyqtSignal(str)
editorOpenedEd = pyqtSignal(Editor)
editorClosed = pyqtSignal(str)
editorClosedEd = pyqtSignal(Editor)
editorRenamed = pyqtSignal(str)
editorRenamedEd = pyqtSignal(Editor)
editorSaved = pyqtSignal(str)
editorSavedEd = pyqtSignal(Editor)
checkActions = pyqtSignal(Editor)
cursorChanged = pyqtSignal(Editor)
breakpointToggled = pyqtSignal(Editor)
bookmarkToggled = pyqtSignal(Editor)
syntaxerrorToggled = pyqtSignal(Editor)
previewStateChanged = pyqtSignal(bool)
editorLanguageChanged = pyqtSignal(Editor)
editorTextChanged = pyqtSignal(Editor)
editorLineChanged = pyqtSignal(str, int)
def __init__(self, parent):
"""
Constructor
@param parent parent widget (QWidget)
"""
self.stacks = []
QSplitter.__init__(self, parent)
ViewManager.__init__(self)
self.setChildrenCollapsible(False)
self.viewlist = QListWidget(self)
policy = self.viewlist.sizePolicy()
policy.setHorizontalPolicy(QSizePolicy.Ignored)
self.viewlist.setSizePolicy(policy)
self.addWidget(self.viewlist)
self.viewlist.setContextMenuPolicy(Qt.CustomContextMenu)
self.viewlist.currentRowChanged.connect(self.__showSelectedView)
self.viewlist.customContextMenuRequested.connect(self.__showMenu)
self.stackArea = QSplitter(self)
self.stackArea.setChildrenCollapsible(False)
self.addWidget(self.stackArea)
self.stackArea.setOrientation(Qt.Vertical)
stack = StackedWidget(self.stackArea)
self.stackArea.addWidget(stack)
self.stacks.append(stack)
self.currentStack = stack
stack.currentChanged.connect(self.__currentChanged)
stack.installEventFilter(self)
self.setSizes([int(self.width() * 0.2), int(self.width() * 0.8)])
# 20% for viewlist, 80% for the editors
self.__inRemoveView = False
self.__initMenu()
self.contextMenuEditor = None
self.contextMenuIndex = -1
def __initMenu(self):
"""
Private method to initialize the viewlist context menu.
"""
self.__menu = QMenu(self)
self.__menu.addAction(
#.........这里部分代码省略.........