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


Python QScrollArea.setMaximumWidth方法代码示例

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


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

示例1: PlotWindow

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setMaximumWidth [as 别名]
class PlotWindow(QWidget):
    def __init__(self, parent):
        super(PlotWindow, self).__init__()
        self.parent = parent

        self.layout = QHBoxLayout()
        graph_layout = QVBoxLayout()
        toolbar_layout = QHBoxLayout()

        self.graph = Graph(self.parent)
        self.graph.toolbar = myNavigationToolbar(self.graph, self.parent)
        self.button_arrow = self.getButtonArrow()
        self.graph.button_vcursor = self.getVerticalCursor()
        self.getColors()
        self.getGroupbox()
        graph_layout.addWidget(self.graph)
        toolbar_layout.addWidget(self.graph.toolbar)
        toolbar_layout.addWidget(self.graph.button_vcursor)
        graph_layout.addLayout(toolbar_layout)

        self.layout.addLayout(graph_layout)
        self.layout.addWidget(self.button_arrow)
        self.layout.addWidget(self.scrollArea)

        self.setLayout(self.layout)

    def getGroupbox(self):
        self.groupbox_layout = QVBoxLayout()
        self.groupbox_widget = QWidget()
        self.scrollArea = QScrollArea()
        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setMaximumWidth(325)
        index = 0
        sorted_dict = sorted(self.parent.parent.device_dict.items(), key=operator.itemgetter(0))
        for (device, dict) in sorted_dict:
            groupBox = QGroupBox(dict["label_device"])
            groupBox.setStyleSheet("QGroupBox { padding-top: 20 px;border: 1px solid gray; border-radius: 3px}")
            groupBox.setFlat(True)
            grid = QGridLayout()
            groupBox.setLayout(grid)
            sorted_curves = sorted(dict.items(), key=operator.itemgetter(1))
            for i, (keys, curves) in enumerate(sorted_curves):
                if keys != "label_device":
                    combo = self.getComboColor(index, curveName="%s_%s" % (dict["label_device"], curves["label"]))

                    checkbox = QCheckBox(curves["label"], self)
                    checkbox.stateChanged.connect(partial(self.graph.addordelCurve, checkbox,
                                                          label="%s_%s" % (dict["label_device"], curves["label"]),
                                                          type=curves["type"], ylabel=curves["ylabel"],
                                                          unit=curves["unit"],
                                                          tableName=device,
                                                          keyword=keys,
                                                          combo=combo))
                    grid.addWidget(checkbox, i, 1)
                    grid.addWidget(combo, i, 0)
                    index += 1
                    combo_deriv = self.getComboColor(index,
                                                     curveName="%s_d%s_dt" % (dict["label_device"], curves["label"]))
                    checkbox_deriv = QCheckBox("d%s_dt" % curves["label"], self)
                    integ_time = self.getSpinBox()
                    combo_unit = self.getComboUnit(curves["unit"])
                    checkbox_deriv.stateChanged.connect(partial(self.graph.addordelCurve, checkbox_deriv,
                                                                label="%s_d%s_dt" % (
                                                                    dict["label_device"], curves["label"]),
                                                                type="d%s_dt" % curves["type"],
                                                                ylabel="d%s_dt (%s)" % (
                                                                    curves["type"].capitalize(), str(combo_deriv.currentText())),
                                                                unit=curves["unit"],
                                                                tableName=device, keyword=keys,
                                                                combo=combo_deriv, spinbox=integ_time, cmb_unit=combo_unit))
                    grid.addWidget(combo_deriv, i + len(sorted_curves), 0)
                    grid.addWidget(checkbox_deriv, i + len(sorted_curves), 1)
                    grid.addWidget(combo_unit, i + len(sorted_curves), 2)
                    grid.addWidget(integ_time, i + len(sorted_curves), 3)
            self.groupbox_layout.addWidget(groupBox)

        self.button_del_graph = QPushButton("Delete Graph")
        self.button_del_graph.clicked.connect(partial(self.clearLayout, self.layout, True))
        self.groupbox_layout.addWidget(self.button_del_graph)
        self.groupbox_widget.setLayout(self.groupbox_layout)

        self.scrollArea.setWidget(self.groupbox_widget)

    def getColors(self):

        self.color_tab = [(31, 119, 180), (174, 199, 232), (255, 127, 14), (255, 187, 120),
                          (44, 160, 44), (152, 223, 138), (214, 39, 40), (255, 152, 150),
                          (148, 103, 189), (197, 176, 213), (140, 86, 75), (196, 156, 148),
                          (227, 119, 194), (247, 182, 210), (127, 127, 127), (199, 199, 199),
                          (188, 189, 34), (224, 198, 17), (23, 190, 207), (158, 218, 229)]

        for i, colors in enumerate(self.color_tab):
            r, g, b = colors
            self.color_tab[i] = (r / 255., g / 255., b / 255.)
        self.graph.color_tab = self.color_tab

    def getComboColor(self, index, curveName):
        combo_color = QComboBox()
        for i, colors in enumerate(self.color_tab):
            r, g, b = colors
#.........这里部分代码省略.........
开发者ID:CraigLoomis,项目名称:ics_sps_engineering_plotData,代码行数:103,代码来源:plot_window.py

示例2: XNova_MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setMaximumWidth [as 别名]
class XNova_MainWindow(QWidget):

    STATE_NOT_AUTHED = 0
    STATE_AUTHED = 1

    def __init__(self, parent=None):
        super(XNova_MainWindow, self).__init__(parent, Qt.Window)
        # state vars
        self.config_store_dir = './cache'
        self.cfg = configparser.ConfigParser()
        self.cfg.read('config/net.ini', encoding='utf-8')
        self.state = self.STATE_NOT_AUTHED
        self.login_email = ''
        self.cookies_dict = {}
        self._hidden_to_tray = False
        #
        # init UI
        self.setWindowIcon(QIcon(':/i/xnova_logo_64.png'))
        self.setWindowTitle('XNova Commander')
        # main layouts
        self._layout = QVBoxLayout()
        self._layout.setContentsMargins(0, 2, 0, 0)
        self._layout.setSpacing(3)
        self.setLayout(self._layout)
        self._horizontal_layout = QHBoxLayout()
        self._horizontal_layout.setContentsMargins(0, 0, 0, 0)
        self._horizontal_layout.setSpacing(6)
        # flights frame
        self._fr_flights = QFrame(self)
        self._fr_flights.setMinimumHeight(22)
        self._fr_flights.setFrameShape(QFrame.NoFrame)
        self._fr_flights.setFrameShadow(QFrame.Plain)
        # planets bar scrollarea
        self._sa_planets = QScrollArea(self)
        self._sa_planets.setMinimumWidth(125)
        self._sa_planets.setMaximumWidth(125)
        self._sa_planets.setFrameShape(QFrame.NoFrame)
        self._sa_planets.setFrameShadow(QFrame.Plain)
        self._sa_planets.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self._sa_planets.setWidgetResizable(True)
        self._panel_planets = QWidget(self._sa_planets)
        self._layout_pp = QVBoxLayout()
        self._panel_planets.setLayout(self._layout_pp)
        self._lbl_planets = QLabel(self.tr('Planets:'), self._panel_planets)
        self._lbl_planets.setMaximumHeight(32)
        self._layout_pp.addWidget(self._lbl_planets)
        self._layout_pp.addStretch()
        self._sa_planets.setWidget(self._panel_planets)
        #
        # tab widget
        self._tabwidget = XTabWidget(self)
        self._tabwidget.enableButtonAdd(False)
        self._tabwidget.tabCloseRequested.connect(self.on_tab_close_requested)
        self._tabwidget.addClicked.connect(self.on_tab_add_clicked)
        #
        # create status bar
        self._statusbar = XNCStatusBar(self)
        self.set_status_message(self.tr('Not connected: Log in!'))
        #
        # tab widget pages
        self.login_widget = None
        self.flights_widget = None
        self.overview_widget = None
        self.imperium_widget = None
        #
        # settings widget
        self.settings_widget = SettingsWidget(self)
        self.settings_widget.settings_changed.connect(self.on_settings_changed)
        self.settings_widget.hide()
        #
        # finalize layouts
        self._horizontal_layout.addWidget(self._sa_planets)
        self._horizontal_layout.addWidget(self._tabwidget)
        self._layout.addWidget(self._fr_flights)
        self._layout.addLayout(self._horizontal_layout)
        self._layout.addWidget(self._statusbar)
        #
        # system tray icon
        self.tray_icon = None
        show_tray_icon = False
        if 'tray' in self.cfg:
            if (self.cfg['tray']['icon_usage'] == 'show') or \
                    (self.cfg['tray']['icon_usage'] == 'show_min'):
                self.create_tray_icon()
        #
        # try to restore last window size
        ssz = self.load_cfg_val('main_size')
        if ssz is not None:
            self.resize(ssz[0], ssz[1])
        #
        # world initialization
        self.world = XNovaWorld_instance()
        self.world_timer = QTimer(self)
        self.world_timer.timeout.connect(self.on_world_timer)

    # overrides QWidget.closeEvent
    # cleanup just before the window close
    def closeEvent(self, close_event: QCloseEvent):
        logger.debug('closing')
        if self.tray_icon is not None:
#.........这里部分代码省略.........
开发者ID:minlexx,项目名称:xnovacmd,代码行数:103,代码来源:main.py


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