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


Python QMainWindow.setCentralWidget方法代码示例

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


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

示例1: create_window

# 需要导入模块: from qtpy.QtWidgets import QMainWindow [as 别名]
# 或者: from qtpy.QtWidgets.QMainWindow import setCentralWidget [as 别名]
def create_window():
    # Create app and widgets
    app = QApplication(sys.argv)
    win = QMainWindow()
    main_area = QWidget()
    button_area = QWidget()
    scroll_area = QScrollArea()
    button = QPushButton("Start Video")
    btn_grab = QPushButton("Grab Frame")

    # Create layouts
    vbox = QVBoxLayout()
    hbox = QHBoxLayout()

    # Fill Layouts
    vbox.addWidget(scroll_area)
    vbox.addWidget(button_area)
    hbox.addStretch()
    hbox.addWidget(button)
    hbox.addWidget(btn_grab)

    # Assign layouts to widgets
    main_area.setLayout(vbox)
    button_area.setLayout(hbox)
    scroll_area.setLayout(QVBoxLayout())

    # Attach some child widgets directly
    win.setCentralWidget(main_area)

    return app, win, button, btn_grab, scroll_area
开发者ID:mabuchilab,项目名称:Instrumental,代码行数:32,代码来源:camera_gui.py

示例2: create_figure_window

# 需要导入模块: from qtpy.QtWidgets import QMainWindow [as 别名]
# 或者: from qtpy.QtWidgets.QMainWindow import setCentralWidget [as 别名]
def create_figure_window(title=''):
    """Creates a figure in a Qt window. Returns the tuple (window, mplfigure)"""
    win = QMainWindow()
    mplfig = MPLFigure()
    win.setCentralWidget(mplfig.canvas)
    win.setWindowTitle(title)
    return win, mplfig
开发者ID:mabuchilab,项目名称:Instrumental,代码行数:9,代码来源:gui.py

示例3: MyPowerSupply

# 需要导入模块: from qtpy.QtWidgets import QMainWindow [as 别名]
# 或者: from qtpy.QtWidgets.QMainWindow import setCentralWidget [as 别名]
from instrumental.gui import UDoubleSpinBox


class MyPowerSupply(Instrument):
    voltage = ManualFacet(type=float, units='volts')
    current = ManualFacet(type=float, units='amps')


if __name__ == '__main__':
    ps = MyPowerSupply()
    ps.observe('voltage', print)

    app = QApplication(sys.argv)
    win = QMainWindow()
    w = QWidget(win)
    win.setCentralWidget(w)
    fbox = QFormLayout()

    box1 = ps.facets.voltage.create_widget()
    fbox.addRow('Voltage', box1)
    box2 = ps.facets.current.create_widget()
    fbox.addRow('Current', box2)

    def set_box(event):
        box1.setUValue(event.new)
    ps.observe('voltage', set_box)

    def f():
        ps.voltage = '12 V'
    #box2.uValueChanged.connect(f)
开发者ID:mabuchilab,项目名称:Instrumental,代码行数:32,代码来源:manual_instrument.py

示例4: __init__

# 需要导入模块: from qtpy.QtWidgets import QMainWindow [as 别名]
# 或者: from qtpy.QtWidgets.QMainWindow import setCentralWidget [as 别名]
#
#    def __init__(self, holdIt, value):
#        QThread.__init__(self)
#        self.holdIt = holdIt
#        self.value = value
#
#    def run(self):
#        t = time.time()
#        time.sleep(2)
#        self.holdIt.update_duration = time.time() - t
#        print "update finished", self.value

if __name__ == '__main__':
    app = QApplication(sys.argv)
    m = QMainWindow()

    w = QWidget()
    m.setCentralWidget(w)
    vlayout = QVBoxLayout(w)
    s_log = LogaritmicSliderSpinBox(m, slider_steps=100)
    s_lin = SliderSpinBox(m, slider_steps=100)
    s_pol = PolynomialSliderSpinBox(m, 2, slider_steps=100, spinbox_steps=1000)
    vlayout.addWidget(s_lin)
    vlayout.addWidget(s_log)
    vlayout.addWidget(s_pol)
    #m.setCentralWidget(s)

    s_log.set_range((0.001, 1000))
    m.show()
    sys.exit(app.exec_())
开发者ID:madsmpedersen,项目名称:MMPE,代码行数:32,代码来源:SliderSpinBox.py

示例5: PlotWindow

# 需要导入模块: from qtpy.QtWidgets import QMainWindow [as 别名]
# 或者: from qtpy.QtWidgets.QMainWindow import setCentralWidget [as 别名]
class PlotWindow(QMdiSubWindow):
    """
    Displayed plotting subwindow available in the ``QMdiArea``.
    """
    window_removed = Signal()
    color_changed = Signal(PlotDataItem, QColor)
    width_changed = Signal(int)

    def __init__(self, model, *args, **kwargs):
        super(PlotWindow, self).__init__(*args, **kwargs)
        # Hide the icon in the title bar
        self.setWindowIcon(qta.icon('fa.circle', opacity=0))

        # The central widget of the sub window will be a main window so that it
        # can support having tab bars
        self._central_widget = QMainWindow()
        self.setWidget(self._central_widget)

        loadUi(os.path.join(os.path.dirname(__file__), "ui", "plot_window.ui"),
               self._central_widget)

        # The central widget of the main window widget will be the plot
        self._model = model
        self._current_item_index = None

        self._plot_widget = PlotWidget(model=self._model)
        self._plot_widget.plotItem.setMenuEnabled(False)

        self._central_widget.setCentralWidget(self._plot_widget)

        # Setup action group for interaction modes
        mode_group = QActionGroup(self.tool_bar)
        mode_group.addAction(self._central_widget.pan_mode_action)
        self._central_widget.pan_mode_action.setChecked(True)
        mode_group.addAction(self._central_widget.zoom_mode_action)

        def _toggle_mode(state):
            view_state = self.plot_widget.plotItem.getViewBox().state.copy()
            view_state.update({'mouseMode': pg.ViewBox.RectMode
                               if state else pg.ViewBox.PanMode})
            self.plot_widget.plotItem.getViewBox().setState(view_state)

        # Setup plot settings options menu
        self.plot_settings_button = self.tool_bar.widgetForAction(
            self._central_widget.plot_settings_action)
        self.plot_settings_button.setPopupMode(QToolButton.InstantPopup)

        self.plot_settings_menu = QMenu(self.plot_settings_button)
        self.plot_settings_button.setMenu(self.plot_settings_menu)

        self.color_change_action = QAction("Line Color")
        self.plot_settings_menu.addAction(self.color_change_action)

        self.line_width_menu = QMenu("Line Widths")
        self.plot_settings_menu.addMenu(self.line_width_menu)

        # Setup the line width plot setting options
        for i in range(1, 4):
            act = QAction(str(i), self.line_width_menu)
            self.line_width_menu.addAction(act)
            act.triggered.connect(lambda *args, size=i:
                                  self._on_change_width(size))

        # Setup connections
        self._central_widget.pan_mode_action.triggered.connect(
            lambda: _toggle_mode(False))
        self._central_widget.zoom_mode_action.triggered.connect(
            lambda: _toggle_mode(True))
        self._central_widget.linear_region_action.triggered.connect(
            self.plot_widget._on_add_linear_region)
        self._central_widget.remove_region_action.triggered.connect(
            self.plot_widget._on_remove_linear_region)
        self.color_change_action.triggered.connect(
            self._on_change_color)
        self._central_widget.export_plot_action.triggered.connect(
            self._on_export_plot)
        self._central_widget.reset_view_action.triggered.connect(
            lambda: self._on_reset_view())

    @property
    def tool_bar(self):
        """
        Return the tool bar for the embedded plot widget.
        """
        return self._central_widget.tool_bar

    @property
    def current_item(self):
        """
        The currently selected plot data item.
        """
        if self._current_item_index is not None:
            return self.proxy_model.item_from_index(self._current_item_index)

    @property
    def plot_widget(self):
        """
        Return the embedded plot widget
        """
        return self._plot_widget
#.........这里部分代码省略.........
开发者ID:nmearl,项目名称:specviz,代码行数:103,代码来源:plotting.py


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