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


Python QtWidgets.QStackedWidget类代码示例

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


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

示例1: FormComboWidget

class FormComboWidget(QWidget):
    def __init__(self, datalist, comment="", parent=None):
        QWidget.__init__(self, parent)
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.combobox = QComboBox()
        layout.addWidget(self.combobox)
        
        self.stackwidget = QStackedWidget(self)
        layout.addWidget(self.stackwidget)
        self.combobox.currentIndexChanged[int].connect(self.stackwidget,setCurrentIndex)
        
        self.widgetlist = []
        for data, title, comment in datalist:
            self.combobox.addItem(title)
            widget = FormWidget(data, comment=comment, parent=self)
            self.stackwidget.addWidget(widget)
            self.widgetlist.append(widget)
            
    def setup(self):
        for widget in self.widgetlist:
            widget.setup()

    def get(self):
        return [ widget.get() for widget in self.widgetlist]
开发者ID:elcritch,项目名称:formlayout5,代码行数:25,代码来源:formlayout5.py

示例2: Window

class Window(QWidget):
    """
    This part might be removed or included for main window application
    """

    def __init__(self, algorithms):
        super(Window, self).__init__()

        self.stackedWidget = QStackedWidget()
        self.orientationCombo = QComboBox()

        for category in categories:
            pass



        for algorithm in algorithms:
            self.orientationCombo.addItem(algorithm.get_name())
            self.stackedWidget.addWidget(GroupOfSliders(algorithm))

            layout = QBoxLayout(QBoxLayout.TopToBottom)

            settings_layout = QBoxLayout(QBoxLayout.TopToBottom)
            settings_layout.addWidget(self.stackedWidget)

            select_layout = QBoxLayout(QBoxLayout.TopToBottom)
            select_layout.addWidget(self.orientationCombo)

            layout.addItem(settings_layout)
            layout.addItem(select_layout)

            self.setLayout(layout)
            self.setWindowTitle(algorithm.get_name() + " Settings")
开发者ID:andreasfirczynski,项目名称:NetworkExtractionFromImages,代码行数:33,代码来源:SettingsWidget.py

示例3: AddItemDialog

class AddItemDialog(QDialog):
    def __init__(self):
        super(AddItemDialog, self).__init__()
        self.setupUi(self)

    def setupUi(self, AddItemDialog):
        self.item_type_picker = QComboBox()

        self.item_properties_switch = QStackedWidget()

        for form in FORMS:
            self.item_type_picker.addItem(form.__name__.split('_')[0],
                                          FORMS.index(form))
            self.item_properties_switch.addWidget(form())

        self.item_type_picker.currentIndexChanged.connect(
            self.item_properties_switch.setCurrentIndex)

        self.add_button = QPushButton("Add")

        mainLayout = QVBoxLayout(self)
        mainLayout.addWidget(self.item_type_picker)
        mainLayout.addWidget(self.item_properties_switch, 1)
        mainLayout.addWidget(self.add_button)

        self.add_button.clicked.connect(self.add_item)

        self.setWindowIcon(QIcon(QPixmap('hotel_icon.jpg')))
        self.layout().setSizeConstraint(QLayout.SetFixedSize)
        self.setWindowTitle("Add Items")

    def add_item(self):
        self.item_properties_switch.currentWidget().add_button_click()
开发者ID:esevlogiev,项目名称:FrontDesk-System,代码行数:33,代码来源:add_item.py

示例4: MainWindow

class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()

        self.centralWidget = QStackedWidget()
        self.setCentralWidget(self.centralWidget)
        startWidget = StartWidget(self)
        self.centralWidget.addWidget(startWidget)

        self.setWindowTitle("Mountain King")
        self.resize(210, 50)

    def host(self):
        hostWidget = HostWidget(self)
        self.centralWidget.addWidget(hostWidget)
        self.centralWidget.setCurrentWidget(hostWidget)

        self.setWindowTitle("Hosting Mountain King")
        self.resize(255, 50)

    def join(self):
        joinWidget = JoinWidget(self)
        self.centralWidget.addWidget(joinWidget)
        self.centralWidget.setCurrentWidget(joinWidget)

        self.setWindowTitle("Joining Mountain King")
        self.resize(255, 50)
开发者ID:T-Dimov,项目名称:Mountain-King,代码行数:27,代码来源:Mountain_King.py

示例5: setCurrentIndex

 def setCurrentIndex(self, index):
     """Change the current widget being displayed with an animation."""
     old_widget = self.currentWidget()
     new_widget = self.widget(index)
     if old_widget != new_widget:
         self.fader_widget = ui_tools.FaderWidget(self.currentWidget(),
                                                  self.widget(index))
     QStackedWidget.setCurrentIndex(self, index)
开发者ID:ninja-ide,项目名称:ninja-ide,代码行数:8,代码来源:tools_dock.py

示例6: Root

class Root(QMainWindow):
    task_list_index = 0
    task_view_index = 1

    def __init__(self):
        super().__init__()
        self.model = None
        self.task_view = None
        self.initUI()

    def initUI(self):
        # self.cal = QCalendarWidget(self)
        # self.cal.setVerticalHeaderFormat(QCalendarWidget.NoVerticalHeader)
        # self.cal.setGeometry(0, 0, 250, 250)

        self.model = TaskModel()
        self.central = QStackedWidget()

        task_list = TaskList(self.model)
        task_list.open.connect(self.task_open)
        self.central.insertWidget(Root.task_list_index, task_list)

        self.task_view = TaskView(self.model)
        self.task_view.close.connect(self.task_view_close)
        self.central.insertWidget(Root.task_view_index, self.task_view)

        self.central.setCurrentIndex(Root.task_list_index)
        self.setCentralWidget(self.central)

        # QDialog flags:
        #   Qt.Dialog |
        #   Qt.WindowTitleHint |
        #   Qt.WindowSystemMenuHint |
        #   Qt.WindowContextHelpButtonHint |
        #   Qt.WindowCloseButtonHint
        self.setWindowFlags(Qt.Dialog | Qt.WindowStaysOnTopHint)
        self.setGeometry(700, 300, 250, 300)
        self.setWindowTitle('Calendar')

    @pyqtSlot(int)
    def task_open(self, index):
        self.task_view.set_task(index)
        self.central.setCurrentIndex(Root.task_view_index)

    @pyqtSlot()
    def task_view_close(self):
        self.central.setCurrentIndex(Root.task_list_index)

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.close()
开发者ID:ReanGD,项目名称:py-org-calendar,代码行数:51,代码来源:main.py

示例7: Window

class Window(QWidget):
    def __init__(self, all_algorithms):
        super(Window, self).__init__()

        self.stackedWidget = QStackedWidget()
        for item in algorithms:
            widget = GuiElement(item)
            self.stackedWidget.addWidget(widget)

        layout = QHBoxLayout()
        layout.addWidget(self.stackedWidget)
        self.setLayout(layout)

        self.setWindowTitle("Algorithm Settings")
开发者ID:andreasfirczynski,项目名称:NetworkExtractionFromImages,代码行数:14,代码来源:DynamUiElementController.py

示例8: Window

class Window(QWidget):
    def __init__(self, title):
        super(Window, self).__init__()

        self.horizontalSliders = SlidersGroup(title)

        self.stackedWidget = QStackedWidget()
        self.stackedWidget.addWidget(self.horizontalSliders)

        layout = QHBoxLayout()
        layout.addWidget(self.stackedWidget)
        self.setLayout(layout)

        self.setWindowTitle("Algorithm Settings: ")
开发者ID:andreasfirczynski,项目名称:NetworkExtractionFromImages,代码行数:14,代码来源:GuiTester.py

示例9: initUI

    def initUI(self):

        # create menus
        menu.GuiMenu()
        menu.WidgetMenu()
        menu.SettingsMenu()
        menu.LoggingMenu()

        # main layout
        mainVLayout = QVBoxLayout()
        elementHLayouts = []

        # top element: toolbar, status
        t = QLabel("Toolbar")
        s = QLabel("Status")
        toolbarStatusHLayout = QHBoxLayout()
        toolbarStatusHLayout.addWidget(t)
        toolbarStatusHLayout.addWidget(s)
        elementHLayouts.append(toolbarStatusHLayout)

        # mid element: menu buttons
        menubuttonsHLayout = QHBoxLayout()
        stackedButtonsWidget = QStackedWidget()
        buttonGroup = QButtonGroup(self)
        buttonGroup.setExclusive(True)

        for m in menu.Menu.menus:
            btn = QPushButton(m.name)
            btn.setCheckable(True)
            btn.pressed.connect(lambda m=m: stackedButtonsWidget.setCurrentWidget(m))
            menubuttonsHLayout.addWidget(btn)
            buttonGroup.addButton(btn)
            stackedButtonsWidget.addWidget(m)

        elementHLayouts.append(menubuttonsHLayout)

        # bot element: menu specific widgets
        menuwidgetsHLayout = QHBoxLayout()
        menuwidgetsHLayout.addWidget(stackedButtonsWidget)
        elementHLayouts.append(menuwidgetsHLayout)

        # click first button for defined initial state
        if len(buttonGroup.buttons()) > 0:
            buttonGroup.buttons()[0].click()

        for l in elementHLayouts:
            mainVLayout.addLayout(l)

        self.setLayout(mainVLayout)
开发者ID:JBrinkmann,项目名称:spyge,代码行数:49,代码来源:spyge.py

示例10: __init__

    def __init__(self, ref_templates, parent=None):
        super().__init__(parent)

        # Variables sections.

        # NB: Sorted.
        self._types = ["book", "bookSection", "conferencePaper", "document",
                       "forumPost", "journalArticle", "patent", "report",
                       "thesis", "webpage"]
        templates_subset = OrderedDict([(k, v) for k, v in ref_templates.items()
                                        if k in self._types])

        # Own configuration section.

        # TODO Better layout configuration.
        self.setMinimumSize(QSize(800, 1000))

        # Widgets section.

        # TODO Prevent edition of the reference type for an existing reference?
        self._types_edit = QComboBox()
        self._types_edit.addItems(self._types)

        self._types_widgets = self._templates_widgets(templates_subset)
        types_forms = self._templates_forms(self._types_widgets)
        forms_stack = QStackedWidget()
        for x in types_forms:
            forms_stack.addWidget(x)

        # NB: The first button with the accept role is made the default button.
        ok_cancel = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        # Layouts section.

        layout = QFormLayout()
        layout.addRow(self.ITEM_TYPE_FIELD + ":", self._types_edit)
        layout.addRow(forms_stack)
        layout.addRow(ok_cancel)
        # NB: Don't use AllNonFixedFieldsGrow because it expands the QComboBox.
        layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
        utils.configure_form_layout(layout)
        self.setLayout(layout)

        # Signals section.

        self._types_edit.currentIndexChanged.connect(forms_stack.setCurrentIndex)
        ok_cancel.accepted.connect(self.accept)
        ok_cancel.rejected.connect(self.reject)
开发者ID:christian-oreilly,项目名称:neurocurator,代码行数:48,代码来源:zotero_edition.py

示例11: __init__

    def __init__(self):
        super(Posttid, self).__init__()

        # Set up the main window ui including parameters such as window size and global font
        self.set_up_window()

        # Load in the saved email and requests
        self.data, self.email, self.requests = self.load()

        # Set up each individual window screen
        self.central_widget = QStackedWidget()
        self.settings_widget = SettingsWindow(self.email, self.requests, parent=self)
        self.status_widget = StatusWindow(parent=self)
        self.central_widget.addWidget(self.status_widget)
        self.central_widget.addWidget(self.settings_widget)
        self.setCentralWidget(self.central_widget)

        # Start a new background thread to run the requests
        self.worker = Worker()
        self.worker.set_values(self.email, self.requests)
        self.worker.missing_email_signal.connect(self.log.missing_email)
        self.worker.connect_signal.connect(self.log.connection)
        self.worker.reconnect_signal.connect(self.log.reconnect)
        self.worker.request_signal.connect(self.log.request_found)
        self.worker.connectionerror_signal.connect(self.log.no_connection)
        self.worker.subreddit_noexist_signal.connect(self.log.subreddit_noexists)
        self.worker.status_condition_signal.connect(self.status_widget.set_status)
        self.worker.timeout_signal.connect(self.log.timeout)
        self.worker.httperror_signal.connect(self.log.http)
        self.worker.test_inside_loop.connect(self.log.inside_loop)
        self.worker.test_query_requests.connect(self.log.query_requests)
        self.worker.start()

        # Stop the worker thread when accessing the settings window
        self.status_widget.settings.clicked.connect(self.worker.terminate)
开发者ID:kevin-lam,项目名称:Posdit,代码行数:35,代码来源:ui.py

示例12: __init__

    def __init__(self, parent=None):
        """Initialize the preferences dialog with a list box and a content layout."""
        super(PreferencesDialog, self).__init__(parent)
        self.setWindowTitle('Preferences')

        settings_icon = utilities.resource_filename('mosaic.images', 'md_settings.png')
        self.setWindowIcon(QIcon(settings_icon))
        self.resize(600, 450)

        self.contents = QListWidget()
        self.contents.setFixedWidth(175)
        self.pages = QStackedWidget()
        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok)

        self.dialog_media_library = MediaLibrary()
        self.dialog_playback = Playback()
        self.dialog_view_options = ViewOptions()
        self.pages.addWidget(self.dialog_media_library)
        self.pages.addWidget(self.dialog_playback)
        self.pages.addWidget(self.dialog_view_options)
        self.list_items()

        stack_layout = QVBoxLayout()
        stack_layout.addWidget(self.pages)
        stack_layout.addWidget(self.button_box)

        layout = QHBoxLayout()
        layout.addWidget(self.contents)
        layout.addLayout(stack_layout)

        self.setLayout(layout)

        self.contents.currentItemChanged.connect(self.change_page)
        self.button_box.accepted.connect(self.accept)
开发者ID:mandeepbhutani,项目名称:Mosaic,代码行数:34,代码来源:configuration.py

示例13: __init__

    def __init__(self, algorithms):
        super(Window, self).__init__()

        self.stackedWidget = QStackedWidget()
        self.orientationCombo = QComboBox()

        for category in categories:
            pass



        for algorithm in algorithms:
            self.orientationCombo.addItem(algorithm.get_name())
            self.stackedWidget.addWidget(GroupOfSliders(algorithm))

            layout = QBoxLayout(QBoxLayout.TopToBottom)

            settings_layout = QBoxLayout(QBoxLayout.TopToBottom)
            settings_layout.addWidget(self.stackedWidget)

            select_layout = QBoxLayout(QBoxLayout.TopToBottom)
            select_layout.addWidget(self.orientationCombo)

            layout.addItem(settings_layout)
            layout.addItem(select_layout)

            self.setLayout(layout)
            self.setWindowTitle(algorithm.get_name() + " Settings")
开发者ID:andreasfirczynski,项目名称:NetworkExtractionFromImages,代码行数:28,代码来源:SettingsWidget.py

示例14: __init__

    def __init__(self):
        super(Window, self).__init__()

        self.horizontalSliders = SlidersGroup(Qt.Horizontal,
                "Horizontal")
        self.verticalSliders = SlidersGroup(Qt.Vertical, "Vertical")

        self.stackedWidget = QStackedWidget()
        self.stackedWidget.addWidget(self.horizontalSliders)
        self.stackedWidget.addWidget(self.verticalSliders)

        self.createControls("Controls")

        self.horizontalSliders.valueChanged.connect(self.verticalSliders.setValue)
        self.verticalSliders.valueChanged.connect(self.valueSpinBox.setValue)
        self.valueSpinBox.valueChanged.connect(self.horizontalSliders.setValue)

        layout = QHBoxLayout()
        layout.addWidget(self.controlsGroup)
        layout.addWidget(self.stackedWidget)
        self.setLayout(layout)

        self.minimumSpinBox.setValue(0)
        self.maximumSpinBox.setValue(20)
        self.valueSpinBox.setValue(5)

        self.setWindowTitle("Sliders")
开发者ID:death-finger,项目名称:Scripts,代码行数:27,代码来源:sliders.py

示例15: __init__

 def __init__(self, QWidget_parent=None):
     super(XTabWidget, self).__init__(QWidget_parent)
     # setup self frame
     self.setFrameShadow(QFrame.Raised)
     # self.setFrameShape(QFrame.StyledPanel)
     self.setFrameShape(QFrame.NoFrame)
     # layouts
     self._layout = QVBoxLayout()
     self._layout.setContentsMargins(0, 0, 0, 0)
     self._layout.setSpacing(2)
     self._layout_top = QHBoxLayout()
     self._layout_top.setContentsMargins(0, 0, 0, 0)
     # stacked widget
     self._stack = QStackedWidget(self)
     # tab bar
     self._tabbar = QTabBar(self)
     self._tabbar.setTabsClosable(True)
     self._tabbar.setMovable(False)
     self._tabbar.setExpanding(False)
     self._tabbar.setShape(QTabBar.RoundedNorth)
     self._tabbar.currentChanged.connect(self.on_tab_current_changed)
     self._tabbar.tabCloseRequested.connect(self.on_tab_close_requested)
     # button "add"
     self._btn_add = QPushButton('+', self)
     self._btn_add.setMaximumSize(QSize(22, 22))
     self._btn_add.clicked.connect(self.on_btn_add_clicked)
     # complete layout
     self._layout_top.addWidget(self._btn_add, 0, Qt.AlignVCenter)
     self._layout_top.addWidget(self._tabbar, 1, Qt.AlignVCenter)
     self._layout.addLayout(self._layout_top)
     self._layout.addWidget(self._stack)
     self.setLayout(self._layout)
开发者ID:minlexx,项目名称:xnovacmd,代码行数:32,代码来源:xtabwidget.py


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