当前位置: 首页>>代码示例>>Python>>正文


Python QSplitter.setMaximumHeight方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QSplitter.setMaximumHeight方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.setMaximumHeight方法的具体用法?Python QSplitter.setMaximumHeight怎么用?Python QSplitter.setMaximumHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QSplitter的用法示例。


在下文中一共展示了QSplitter.setMaximumHeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BusMonitorWindow

# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setMaximumHeight [as 别名]
class BusMonitorWindow(QMainWindow):
    DEFAULT_PLOT_X_RANGE = 120
    BUS_LOAD_PLOT_MAX_SAMPLES = 50000

    def __init__(self, get_frame, iface_name):
        super(BusMonitorWindow, self).__init__()
        self.setWindowTitle('CAN bus monitor (%s)' % iface_name.split(os.path.sep)[-1])
        self.setWindowIcon(get_app_icon())

        self._get_frame = get_frame

        self._log_widget = RealtimeLogWidget(self, columns=COLUMNS, font=get_monospace_font(),
                                             pre_redraw_hook=self._redraw_hook)
        self._log_widget.on_selection_changed = self._update_measurement_display

        self._log_widget.table.cellClicked.connect(lambda row, col: self._decode_transfer_at_row(row))

        self._log_widget.table.setContextMenuPolicy(Qt.CustomContextMenu)
        self._log_widget.table.customContextMenuRequested.connect(self._context_menu_requested)

        self._stat_display = QLabel('0 / 0 / 0', self)
        stat_display_label = QLabel('TX / RX / FPS: ', self)
        stat_display_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self._log_widget.custom_area_layout.addWidget(stat_display_label)
        self._log_widget.custom_area_layout.addWidget(self._stat_display)

        def flip_row_mark(row, col):
            if col == 0:
                item = self._log_widget.table.item(row, col)
                if item.icon().isNull():
                    item.setIcon(get_icon('circle'))
                    flash(self, 'Row %d was marked, click again to unmark', row, duration=3)
                else:
                    item.setIcon(QIcon())

        self._log_widget.table.cellPressed.connect(flip_row_mark)

        self._stat_update_timer = QTimer(self)
        self._stat_update_timer.setSingleShot(False)
        self._stat_update_timer.timeout.connect(self._update_stat)
        self._stat_update_timer.start(500)

        self._traffic_stat = TrafficStatCounter()

        self._decoded_message_box = QPlainTextEdit(self)
        self._decoded_message_box.setReadOnly(True)
        self._decoded_message_box.setFont(get_monospace_font())
        self._decoded_message_box.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self._decoded_message_box.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self._decoded_message_box.setPlainText('Click on a row to see decoded transfer')
        self._decoded_message_box.setLineWrapMode(QPlainTextEdit.NoWrap)
        self._decoded_message_box.setWordWrapMode(QTextOption.NoWrap)

        self._load_plot = PlotWidget(background=(0, 0, 0))
        self._load_plot.setRange(xRange=(0, self.DEFAULT_PLOT_X_RANGE), padding=0)
        self._load_plot.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        self._load_plot.showGrid(x=True, y=True, alpha=0.4)
        self._load_plot.setToolTip('Frames per second')
        self._load_plot.getPlotItem().getViewBox().setMouseEnabled(x=True, y=False)
        self._load_plot.enableAutoRange()
        self._bus_load_plot = self._load_plot.plot(name='Frames per second', pen=mkPen(QColor(Qt.lightGray), width=1))
        self._bus_load_samples = [], []
        self._started_at_mono = time.monotonic()

        self._footer_splitter = QSplitter(Qt.Horizontal, self)
        self._footer_splitter.addWidget(self._decoded_message_box)
        self._decoded_message_box.setMinimumWidth(400)
        self._footer_splitter.addWidget(self._load_plot)
        self._load_plot.setMinimumWidth(200)

        splitter = QSplitter(Qt.Vertical, self)
        splitter.addWidget(self._log_widget)
        self._log_widget.setMinimumHeight(200)
        splitter.addWidget(self._footer_splitter)

        widget = QWidget(self)
        layout = QHBoxLayout(widget)
        layout.addWidget(splitter)
        widget.setLayout(layout)

        self.setCentralWidget(widget)
        self.setMinimumWidth(700)
        self.resize(800, 600)

        # Calling directly from the constructor gets you wrong size information
        # noinspection PyCallByClass,PyTypeChecker
        QTimer.singleShot(500, self._update_widget_sizes)

    def _update_widget_sizes(self):
        max_footer_height = self.centralWidget().height() * 0.4
        self._footer_splitter.setMaximumHeight(max_footer_height)

    def resizeEvent(self, qresizeevent):
        super(BusMonitorWindow, self).resizeEvent(qresizeevent)
        self._update_widget_sizes()

    def _update_stat(self):
        bus_load, ts_mono = self._traffic_stat.get_frames_per_second()

        if len(self._bus_load_samples[0]) >= self.BUS_LOAD_PLOT_MAX_SAMPLES:
#.........这里部分代码省略.........
开发者ID:UAVCAN,项目名称:gui_tool,代码行数:103,代码来源:window.py


注:本文中的PyQt5.QtWidgets.QSplitter.setMaximumHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。