本文整理汇总了Python中PyQt5.QtWidgets.QSplitter.setChildrenCollapsible方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.setChildrenCollapsible方法的具体用法?Python QSplitter.setChildrenCollapsible怎么用?Python QSplitter.setChildrenCollapsible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QSplitter
的用法示例。
在下文中一共展示了QSplitter.setChildrenCollapsible方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sig_to_stems_clicked
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setChildrenCollapsible [as 别名]
def sig_to_stems_clicked(self, row):
signature = self.sig_to_stems_major_table.item(row, 0).text()
print(signature)
signature = tuple(signature.split(SEP_SIG))
stems = sorted(self.lexicon.signatures_to_stems()[signature])
number_of_stems_per_column = 5
# create a master list of sublists, where each sublist contains k stems
# k = number_of_stems_per_column
stem_rows = list()
stem_row = list()
for i, stem in enumerate(stems, 1):
stem_row.append(stem)
if not i % number_of_stems_per_column:
stem_rows.append(stem_row)
stem_row = list()
if stem_row:
stem_rows.append(stem_row)
# set up the minor table as table widget
sig_to_stems_minor_table = QTableWidget()
sig_to_stems_minor_table.horizontalHeader().hide()
sig_to_stems_minor_table.verticalHeader().hide()
sig_to_stems_minor_table.clear()
sig_to_stems_minor_table.setRowCount(len(stem_rows))
sig_to_stems_minor_table.setColumnCount(number_of_stems_per_column)
# fill in the minor table
for row, stem_row in enumerate(stem_rows):
for col, stem in enumerate(stem_row):
item = QTableWidgetItem(stem)
sig_to_stems_minor_table.setItem(row, col, item)
sig_to_stems_minor_table.resizeColumnsToContents()
minor_table_title = QLabel('{} (number of stems: {})'
.format(SEP_SIG.join(signature), len(stems)))
minor_table_widget_with_title = QWidget()
layout = QVBoxLayout()
layout.addWidget(minor_table_title)
layout.addWidget(sig_to_stems_minor_table)
minor_table_widget_with_title.setLayout(layout)
new_display = QSplitter(Qt.Horizontal)
new_display.setHandleWidth(10)
new_display.setChildrenCollapsible(False)
new_display.addWidget(self.sig_to_stems_major_table)
new_display.addWidget(minor_table_widget_with_title)
new_display_width = self.majorDisplay.width() / 2
new_display.setSizes(
[new_display_width * 0.4, new_display_width * 0.6])
self.load_main_window(major_display=new_display)
self.status.clearMessage()
self.status.showMessage('{} selected'.format(signature))
示例2: getSplitter
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setChildrenCollapsible [as 别名]
def getSplitter(self):
splitter = QSplitter(Qt.Horizontal)
# Give both boxes a minimum size so the minimumSizeHint will be
# ignored when splitter.setSizes is called below
for widget in self.editBox, self.previewBox:
widget.setMinimumWidth(125)
splitter.addWidget(widget)
splitter.setSizes((50, 50))
splitter.setChildrenCollapsible(False)
return splitter
示例3: NetWorthView
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setChildrenCollapsible [as 别名]
class NetWorthView(AccountSheetView):
def _setup(self):
self._setupUi()
self.sheet = self.nwsheet = NetWorthSheet(self.model.bsheet, view=self.treeView)
self.graph = self.nwgraph = Chart(self.model.nwgraph, view=self.graphView)
self.piechart = Chart(self.model.pie, view=self.pieChart)
def _setupUi(self):
self.resize(558, 447)
self.mainLayout = QVBoxLayout(self)
self.mainLayout.setSpacing(0)
self.mainLayout.setContentsMargins(0, 0, 0, 0)
self.splitterView = QSplitter()
self.splitterView.setChildrenCollapsible(False)
self.splitterView.setOrientation(Qt.Vertical)
self.subSplitterView = QSplitter()
self.subSplitterView.setChildrenCollapsible(False)
self.treeView = TreeView(self)
self.treeView.setAcceptDrops(True)
self.treeView.setFrameShape(QFrame.NoFrame)
self.treeView.setFrameShadow(QFrame.Plain)
self.treeView.setEditTriggers(QAbstractItemView.EditKeyPressed|QAbstractItemView.SelectedClicked)
self.treeView.setDragEnabled(True)
self.treeView.setDragDropMode(QAbstractItemView.InternalMove)
self.treeView.setUniformRowHeights(True)
self.treeView.setAllColumnsShowFocus(True)
self.treeView.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.treeView.header().setStretchLastSection(False)
self.subSplitterView.addWidget(self.treeView)
self.pieChart = PieChartView(self)
self.pieChart.setMinimumSize(300, 0)
self.subSplitterView.addWidget(self.pieChart)
self.splitterView.addWidget(self.subSplitterView)
self.graphView = LineGraphView(self)
self.graphView.setMinimumSize(0, 200)
self.splitterView.addWidget(self.graphView)
self.splitterView.setStretchFactor(0, 1)
self.splitterView.setStretchFactor(1, 0)
self.subSplitterView.setStretchFactor(0, 1)
self.subSplitterView.setStretchFactor(1, 0)
self.mainLayout.addWidget(self.splitterView)
示例4: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setChildrenCollapsible [as 别名]
#.........这里部分代码省略.........
self.lexicon_tree.expandItem(ancestor)
for item in [WORD_NEIGHBORS, VISUALIZED_GRAPH]:
self.lexicon_tree.expandItem(QTreeWidgetItem(ancestor, [item]))
self.status.clearMessage()
self.status.showMessage('Navigation tree populated')
print('Lexicon navigation tree populated', flush=True)
def load_main_window(self, major_display=None, parameter_window=None):
"""
Refresh the main window for the updated display content
(most probably after a click or some event is triggered)
"""
# get sizes of the three major PyQt objects
major_display_size = self.majorDisplay.size()
parameter_window_size = self.parameterWindow.size()
lexicon_tree_size = self.lexicon_tree.size()
if major_display:
self.majorDisplay = major_display
if parameter_window:
self.parameterWindow = parameter_window
# apply sizes to the major three objects
self.majorDisplay.resize(major_display_size)
self.parameterWindow.resize(parameter_window_size)
self.lexicon_tree.resize(lexicon_tree_size)
# set up:
# 1) main splitter (b/w lexicon-tree+parameter window and major display)
# 2) minor splitter (b/w lexicon-tree and parameter window)
self.mainSplitter = QSplitter(Qt.Horizontal)
self.mainSplitter.setHandleWidth(10)
self.mainSplitter.setChildrenCollapsible(False)
self.minorSplitter = QSplitter(Qt.Vertical)
self.minorSplitter.setHandleWidth(10)
self.minorSplitter.setChildrenCollapsible(False)
self.minorSplitter.addWidget(self.lexicon_tree)
self.minorSplitter.addWidget(self.parameterWindow)
self.mainSplitter.addWidget(self.minorSplitter)
self.mainSplitter.addWidget(self.majorDisplay)
self.setCentralWidget(self.mainSplitter)
def sig_to_stems_clicked(self, row):
signature = self.sig_to_stems_major_table.item(row, 0).text()
print(signature)
signature = tuple(signature.split(SEP_SIG))
stems = sorted(self.lexicon.signatures_to_stems()[signature])
number_of_stems_per_column = 5
# create a master list of sublists, where each sublist contains k stems
# k = number_of_stems_per_column
stem_rows = list()
stem_row = list()
for i, stem in enumerate(stems, 1):
stem_row.append(stem)
if not i % number_of_stems_per_column:
stem_rows.append(stem_row)
stem_row = list()
if stem_row:
示例5: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setChildrenCollapsible [as 别名]
#.........这里部分代码省略.........
act = self.recent_menu.addAction(
'{0} {1} {2}'.format(i,fname,folder)
)
act.triggered.connect( lambda: self._open_recent(path) )
i += 1
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# User has chosen a different font; if it is the general font, set
# that here so it will propogate to our children.
def _font_change(self, is_mono):
if not is_mono:
self.setFont(fonts.get_general())
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Create the UI contained within this QMainWindow object. This is a lean
# main window indeed. We have no toolbar, no status bar, no dock,
# nothing. Just a splitter with, on the left, a tabset for editviews, and
# on the right, a scrollbar containing a tabset for panels. (Qt Designer
# note: it is not possible to build this structure with the Designer. It
# will not let you put the scroll area into the splitter.)
#
# TODO: create a custom QTabWidget using a custom QTabBar to implement
# drag-out-of-tabset behavior, and use those here.
def _uic(self):
# Create the tabset that displays editviews
self.editview_tabset = QTabWidget()
self.editview_tabset.setMovable(True) # let user move tabs around
self.editview_tabset.currentChanged.connect(self._editview_change)
# Create the tabset that displays find, notes, help &etc.
self.panel_tabset = QTabWidget()
self.panel_tabset.setMovable(True)
# Create the splitter that contains the above two parts.
self.splitter = QSplitter(Qt.Horizontal, self)
self.splitter.setChildrenCollapsible(False)
# Give just a little margin to the left of the editor
self.splitter.setContentsMargins(8,0,0,0)
self.splitter.addWidget(self.editview_tabset)
self.splitter.addWidget(self.panel_tabset)
# Set that splitter as the main window's central (and only) widget
self.setCentralWidget(self.splitter)
# Populate the panel tabset with empty widgets just so there will
# be tabs that _swap can reference.
for key in self.panel_dict.keys():
widj = QWidget()
self.panel_tabset.addTab(widj,key)
self.panel_dict[key] = widj
# Size and position ourself based on saved settings.
self.move(self.settings.value("mainwindow/position", QPoint(50,50)))
self.resize(self.settings.value("mainwindow/size", C.STARTUP_DEFAULT_SIZE))
self.splitter.restoreState(
self.settings.value("mainwindow/splitter",C.STARTUP_DEFAULT_SPLITTER) )
# Store a reference to the application menubar. In Mac OS this
# is a parentless menubar; other platforms it is the default.
if C.PLATFORM_IS_MAC :
self.menu_bar = QMenuBar() # parentless menu bar for Mac OS
else :
self.menu_bar = self.menuBar # refer to the default one
set_menu_bar(self.menu_bar)
# Create the File menu, located in our menu_bar.
self.file_menu = self.menu_bar.addMenu(_TR('Menu name', '&File'))
# Populate the File menu with actions.
# File:New -> _new()
work = self.file_menu.addAction( _TR('File menu command','&New') )
work.setShortcut(QKeySequence.New)
work.setToolTip( _TR('File:New tooltip','Create a new, empty document') )
work.triggered.connect(self._new)
示例6: SignalTabController
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setChildrenCollapsible [as 别名]
class SignalTabController(QWidget):
frame_closed = pyqtSignal(SignalFrameController)
not_show_again_changed = pyqtSignal()
signal_created = pyqtSignal(Signal)
files_dropped = pyqtSignal(list)
frame_was_dropped = pyqtSignal(int, int)
@property
def num_frames(self):
return self.splitter.count() - 1
@property
def signal_frames(self):
"""
:rtype: list of SignalFrameController
"""
return [self.splitter.widget(i) for i in range(self.num_frames)]
@property
def signal_undo_stack(self):
return self.undo_stack
def __init__(self, project_manager, parent=None):
super().__init__(parent)
self.ui = Ui_Interpretation()
self.ui.setupUi(self)
self.splitter = QSplitter()
self.splitter.setStyleSheet("QSplitter::handle:vertical {\nmargin: 4px 0px; background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, \nstop:0 rgba(255, 255, 255, 0), \nstop:0.5 rgba(100, 100, 100, 100), \nstop:1 rgba(255, 255, 255, 0));\n image: url(:/icons/data/icons/splitter_handle_horizontal.svg);\n}")
self.splitter.setOrientation(Qt.Vertical)
self.splitter.setChildrenCollapsible(True)
self.splitter.setHandleWidth(6)
placeholder_widget = QWidget()
placeholder_widget.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
self.undo_stack = QUndoStack()
self.project_manager = project_manager
self.splitter.addWidget(placeholder_widget)
self.signal_vlay = QVBoxLayout()
self.signal_vlay.setContentsMargins(0,0,0,0)
self.signal_vlay.addWidget(self.splitter)
self.ui.scrlAreaSignals.setLayout(self.signal_vlay)
self.drag_pos = None
def on_files_dropped(self, files):
self.files_dropped.emit(files)
def close_frame(self, frame:SignalFrameController):
self.frame_closed.emit(frame)
def add_signal_frame(self, proto_analyzer):
sig_frame = SignalFrameController(proto_analyzer, self.undo_stack, self.project_manager, parent=self)
sframes = self.signal_frames
if len(proto_analyzer.signal.filename) == 0:
# new signal from "create signal from selection"
sig_frame.ui.btnSaveSignal.show()
self.__create_connects_for_signal_frame(signal_frame=sig_frame)
sig_frame.signal_created.connect(self.signal_created.emit)
sig_frame.not_show_again_changed.connect(self.not_show_again_changed.emit)
sig_frame.ui.lineEditSignalName.setToolTip(self.tr("Sourcefile: ") + proto_analyzer.signal.filename)
sig_frame.apply_to_all_clicked.connect(self.on_apply_to_all_clicked)
prev_signal_frame = sframes[-1] if len(sframes) > 0 else None
if prev_signal_frame is not None and hasattr(prev_signal_frame, "ui"):
sig_frame.ui.cbProtoView.setCurrentIndex(prev_signal_frame.ui.cbProtoView.currentIndex())
sig_frame.blockSignals(True)
if proto_analyzer.signal.qad_demod_file_loaded:
sig_frame.ui.cbSignalView.setCurrentIndex(1)
sig_frame.ui.cbSignalView.setDisabled(True)
self.splitter.insertWidget(self.num_frames, sig_frame)
sig_frame.blockSignals(False)
default_view = constants.SETTINGS.value('default_view', 0, int)
sig_frame.ui.cbProtoView.setCurrentIndex(default_view)
return sig_frame
def __create_connects_for_signal_frame(self, signal_frame: SignalFrameController):
signal_frame.hold_shift = constants.SETTINGS.value('hold_shift_to_drag', False, type=bool)
signal_frame.drag_started.connect(self.frame_dragged)
signal_frame.frame_dropped.connect(self.frame_dropped)
signal_frame.files_dropped.connect(self.on_files_dropped)
signal_frame.closed.connect(self.close_frame)
def add_empty_frame(self, filename: str, proto):
sig_frame = SignalFrameController(proto_analyzer=proto, undo_stack=self.undo_stack,
project_manager=self.project_manager, proto_bits=proto.decoded_proto_bits_str,
parent=self)
sig_frame.ui.lineEditSignalName.setText(filename)
sig_frame.setMinimumHeight(sig_frame.height())
sig_frame.set_empty_frame_visibilities()
#.........这里部分代码省略.........
示例7: OTMainWindow
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setChildrenCollapsible [as 别名]
class OTMainWindow(QWidget):
def __init__(self, parent=None):
super(OTMainWindow, self).__init__(parent, Qt.Window)
self.setWindowTitle('OPC Python Tester')
self.layout = QVBoxLayout()
#
self.tree = QTreeWidget(self)
self.tree.setHeaderLabel('OPC server tree')
self.tree_root = QTreeWidgetItem()
self.tree_root.setText(0, 'not connected')
self.tree.addTopLevelItem(self.tree_root)
self.tree.itemDoubleClicked.connect(self.on_tree_item_double_clicked)
#
self.table = QTableWidget(self)
self.table.setRowCount(0)
self.table_column_labels = [
'item_id', 'value', 'type', 'access', 'quality', 'timestamp']
self.table.setColumnCount(len(self.table_column_labels))
self.table.setHorizontalHeaderLabels(self.table_column_labels)
self.table.horizontalHeader().setStretchLastSection(True)
#
self.splitter = QSplitter(Qt.Horizontal, self)
self.splitter.setChildrenCollapsible(False)
self.splitter.setHandleWidth(10)
self.layout.addWidget(self.splitter)
# final
self.splitter.addWidget(self.tree)
self.splitter.addWidget(self.table)
self.splitter.setSizes([150, 300])
self.setLayout(self.layout)
# self.opcsrv = None
self.cur_server_info = {}
self.cur_comp_name = ''
self.watched_itemids = []
self.ssdialog = ServerSelectDialog(self)
ssel_ret = self.ssdialog.exec_()
if ssel_ret == QDialog.Accepted:
self.do_connect(self.ssdialog.selected_server, self.ssdialog.selected_comp_name)
else:
print('Connection cancelled')
self.timer = QTimer(self)
self.timer.timeout.connect(self.on_timer_timeout)
self.timer.start(1000) # every 1 second
def do_connect(self, srv_info: dict, comp_name: str):
print('Connecting to "{0}" ({1}) on comp: {2}...'.format(
srv_info['desc'], srv_info['guid'], comp_name))
self.opcsrv = opc_helper.opc_connect(srv_info['guid'], comp_name)
if self.opcsrv is None:
return
self.cur_comp_name = comp_name
self.cur_server_info = srv_info
print(self.opcsrv.get_status())
self.fill_tree()
def fill_tree(self):
self.tree.clear()
if self.opcsrv is None:
return
self.tree_root = QTreeWidgetItem(self.tree)
self.tree_root.setChildIndicatorPolicy(QTreeWidgetItem.DontShowIndicatorWhenChildless)
root_title = '{0}'.format(self.cur_server_info['desc'])
if self.cur_comp_name != '':
root_title = '{0} ({1})'.format(self.cur_server_info['desc'], self.cur_comp_name)
self.tree_root.setText(0, root_title)
self.tree.addTopLevelItem(self.tree_root)
server_tree = self.opcsrv.browse(flat=False)
#
for oitem in server_tree:
self.fill_item(oitem, self.tree_root)
def fill_item(self, item: dict, parent: QTreeWidgetItem):
tree_item = QTreeWidgetItem()
tree_item.setChildIndicatorPolicy(QTreeWidgetItem.DontShowIndicatorWhenChildless)
tree_item.setText(0, item['name'])
if item['children'] is None:
# set userdata = item_id only if this IS a LEAF node
tree_item.setData(0, Qt.UserRole, item['item_id']) # column, role, data
parent.addChild(tree_item)
# recurse into children
if item['children'] is not None:
for oitem in item['children']:
self.fill_item(oitem, tree_item)
@pyqtSlot(QTreeWidgetItem, int)
def on_tree_item_double_clicked(self, item: QTreeWidgetItem, column: int):
# void itemDoubleClicked(QTreeWidgetItem * item, int column)
# virtual QVariant data(int column, int role) const
item_data = item.data(0, Qt.UserRole)
if item_data is None:
return
item_id = str(item_data)
print('Double click on [{0}]'.format(item_id))
self.opcsrv.get_item(item_id)
if item_id not in self.watched_itemids:
self.watched_itemids.append(item_id)
#.........这里部分代码省略.........
示例8: EntryView
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setChildrenCollapsible [as 别名]
class EntryView(BaseTransactionView):
def _setup(self):
self._setupUi()
self.etable = EntryTable(self.model.etable, view=self.tableView)
self.efbar = EntryFilterBar(model=self.model.filter_bar, view=self.filterBar)
self.bgraph = Chart(self.model.bargraph, view=self.barGraphView)
self.lgraph = Chart(self.model.balgraph, view=self.lineGraphView)
self._setupColumns() # Can only be done after the model has been connected
self.reconciliationButton.clicked.connect(self.model.toggle_reconciliation_mode)
def _setupUi(self):
self.resize(483, 423)
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setSpacing(0)
self.filterBar = RadioBox(self)
sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.filterBar.sizePolicy().hasHeightForWidth())
self.filterBar.setSizePolicy(sizePolicy)
self.horizontalLayout.addWidget(self.filterBar)
self.horizontalLayout.addItem(horizontalSpacer())
self.reconciliationButton = QPushButton(tr("Reconciliation"))
self.reconciliationButton.setCheckable(True)
self.horizontalLayout.addWidget(self.reconciliationButton)
self.verticalLayout.addLayout(self.horizontalLayout)
self.splitterView = QSplitter()
self.splitterView.setOrientation(Qt.Vertical)
self.splitterView.setChildrenCollapsible(False)
self.tableView = TableView(self)
self.tableView.setAcceptDrops(True)
self.tableView.setEditTriggers(QAbstractItemView.DoubleClicked|QAbstractItemView.EditKeyPressed)
self.tableView.setDragEnabled(True)
self.tableView.setDragDropMode(QAbstractItemView.InternalMove)
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
self.tableView.setSortingEnabled(True)
self.tableView.horizontalHeader().setHighlightSections(False)
self.tableView.horizontalHeader().setMinimumSectionSize(18)
self.tableView.verticalHeader().setVisible(False)
self.tableView.verticalHeader().setDefaultSectionSize(18)
self.splitterView.addWidget(self.tableView)
self.graphView = QStackedWidget(self)
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.graphView.sizePolicy().hasHeightForWidth())
self.graphView.setSizePolicy(sizePolicy)
self.graphView.setMinimumSize(0, 200)
self.lineGraphView = LineGraphView()
self.graphView.addWidget(self.lineGraphView)
self.barGraphView = BarGraphView()
self.graphView.addWidget(self.barGraphView)
self.splitterView.addWidget(self.graphView)
self.graphView.setCurrentIndex(1)
self.splitterView.setStretchFactor(0, 1)
self.splitterView.setStretchFactor(1, 0)
self.verticalLayout.addWidget(self.splitterView)
def _setupColumns(self):
h = self.tableView.horizontalHeader()
h.setSectionsMovable(True) # column drag & drop reorder
# --- QWidget override
def setFocus(self):
self.etable.view.setFocus()
# --- Public
def fitViewsForPrint(self, viewPrinter):
hidden = self.model.mainwindow.hidden_areas
viewPrinter.fitTable(self.etable)
if PaneArea.BottomGraph not in hidden:
viewPrinter.fit(self.graphView.currentWidget(), 300, 150, expandH=True, expandV=True)
def restoreSubviewsSize(self):
graphHeight = self.model.graph_height_to_restore
if graphHeight:
splitterHeight = self.splitterView.height()
sizes = [splitterHeight-graphHeight, graphHeight]
self.splitterView.setSizes(sizes)
# --- model --> view
def refresh_reconciliation_button(self):
if self.model.can_toggle_reconciliation_mode:
self.reconciliationButton.setEnabled(True)
self.reconciliationButton.setChecked(self.model.reconciliation_mode)
else:
self.reconciliationButton.setEnabled(False)
self.reconciliationButton.setChecked(False)
def show_bar_graph(self):
self.graphView.setCurrentIndex(1)
def show_line_graph(self):
self.graphView.setCurrentIndex(0)
def update_visibility(self):
#.........这里部分代码省略.........
示例9: Listspace
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setChildrenCollapsible [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(
#.........这里部分代码省略.........