本文整理汇总了Python中PyQt5.QtWidgets.QStackedWidget.sizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QStackedWidget.sizePolicy方法的具体用法?Python QStackedWidget.sizePolicy怎么用?Python QStackedWidget.sizePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QStackedWidget
的用法示例。
在下文中一共展示了QStackedWidget.sizePolicy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EntryView
# 需要导入模块: from PyQt5.QtWidgets import QStackedWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedWidget import sizePolicy [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):
#.........这里部分代码省略.........