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


Python QtWidgets.QBoxLayout类代码示例

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


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

示例1: GUI

class GUI(QDialog):

    def __init__(self, settings):
        super(QDialog, self).__init__()
        self.setWindowTitle("Settings")
        self.setWindowIcon(QIcon('ui/icon.png'))
        self.setModal(True)
        self.setWindowFlags(Qt.WindowStaysOnTopHint)

        self._button_box = QDialogButtonBox(
            QDialogButtonBox.Ok
        )
        self._button_box.button(QDialogButtonBox.Ok).clicked.connect(self.accept)

        self._tabs = QTabWidget()

        self._layout = QBoxLayout(QBoxLayout.TopToBottom)
        self._layout.addWidget(self._tabs)
        self._layout.addWidget(self._button_box)

        self.setLayout(self._layout)

        # setup tabs
        self.tab_list = {}
        self.widgets = {}

        # general tab
        general_tab = GeneralTab(settings)
        self._tabs.addTab(general_tab, general_tab.get_title())
        characters_tab = CharactersTab(settings)
        self._tabs.addTab(characters_tab, characters_tab.get_title())

    def set_show_tab(self, tab):
        if tab == "characters":
            self._tabs.setCurrentIndex(1)
开发者ID:nomns,项目名称:Parse99,代码行数:35,代码来源:gui.py

示例2: __init__

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

        # information widget
        self.plotWidget = VariantPlotWidget()
        self.infoWidget = VariantInfoWidget()

        # splitter settings
        splitter = QSplitter(Qt.Horizontal)
        splitter.addWidget(self.plotWidget)
        splitter.addWidget(self.infoWidget)
        splitter.setStretchFactor(0, 3)
        splitter.setStretchFactor(1, 1)

        # layout
        layout = QBoxLayout(QBoxLayout.TopToBottom)
        layout.addWidget(splitter)
        self.setLayout(layout)

        # connect signals
        self.plotWidget.curvePlotted.connect(self.infoWidget.updateResults)
        self.plotWidget.plotReady.connect(self.infoWidget.showResults)
        self.plotWidget.cleared.connect(self.infoWidget.clear)
        self.infoWidget.legendChanged.connect(self.plotWidget.paintCalculation)

        # translate the graphical user interface
        self.retranslateUi()
开发者ID:tobiashelfenstein,项目名称:wuchshuellenrechner,代码行数:27,代码来源:widget_plot.py

示例3: __init__

    def __init__(self, parent = None, direction = "ltr", rtf = False):
        """ Creates a new QPageWidget on given parent object. 

        parent: QWidget parent
        direction: "ltr" -> Left To Right
                   "ttb" -> Top To Bottom
        rtf: Return to first, if its True it flips to the first page 
             when next page requested at the last page
        """
        # First initialize, QPageWidget is based on QScrollArea
        QScrollArea.__init__(self, parent)

        # Properties for QScrollArea
        self.setFrameShape(QFrame.NoFrame)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setWidgetResizable(True)

        # Main widget, which stores all Pages in it
        self.widget = QWidget(self)

        # Layout based on QBoxLayout which supports Vertical or Horizontal layout
        if direction == "ltr":
            self.layout = QBoxLayout(QBoxLayout.LeftToRight, self.widget)
            self.__scrollBar = self.horizontalScrollBar()
            self.__base_value = self.width
        else:
            self.layout = QBoxLayout(QBoxLayout.TopToBottom, self.widget)
            self.__scrollBar = self.verticalScrollBar()
            self.__base_value = self.height
        self.layout.setSpacing(0)
        self.layout.setMargin(0)

        # Return to first
        self.__return_to_first = rtf

        # TMP_PAGE, its using as last page in stack
        # A workaround for a QScrollArea bug
        self.__tmp_page = Page(QWidget(self.widget))
        self.__pages = [self.__tmp_page]
        self.__current = 0
        self.__last = 0

        # Set main widget
        self.setWidget(self.widget)

        # Animation TimeLine
        self.__timeline = QTimeLine()
        self.__timeline.setUpdateInterval(2)

        # Updates scrollbar position when frame changed
        self.__timeline.frameChanged.connect(lambda x: self.__scrollBar.setValue(x))

        # End of the animation
        self.__timeline.finished.connect(self._animateFinished)

        # Initialize animation
        self.setAnimation()
        self.setDuration()
开发者ID:PisiLinuxRepos,项目名称:pisilinux-desktop-services,代码行数:59,代码来源:qpagewidget.py

示例4: __init__

    def __init__(self, algorithm):
        super(GroupOfSliders, self).__init__()

        GroupOfSliderssLayout = QBoxLayout(QBoxLayout.TopToBottom)
        GroupOfSliders.setFixedHeight(self, 300)

        for slider in algorithm.integer_sliders:
            GroupOfSliderssLayout.addWidget(
                    SliderWidget(slider.name, slider.lower, slider.upper, slider.step_size, slider.default,
                                 False))

        for slider in algorithm.float_sliders:
            GroupOfSliderssLayout.addWidget(
                    SliderWidget(slider.name, slider.lower, slider.upper, slider.step_size, slider.default,
                                 True))

        for checkbox in algorithm.checkboxes:
            GroupOfSliderssLayout.addWidget(
                    CheckBoxWidget(checkbox.name, checkbox.default))

        for dropdown in algorithm.drop_downs:
            GroupOfSliderssLayout.addWidget(
                    ComboBoxWidget(dropdown.name, dropdown.options))

        self.setLayout(GroupOfSliderssLayout)
开发者ID:andreasfirczynski,项目名称:NetworkExtractionFromImages,代码行数:25,代码来源:SettingsWidget.py

示例5: ComboBoxWidget

class ComboBoxWidget(QGroupBox):
    """
    This is the combobox widget as it is shown in the settings
    panel of the GUI. It gets initialized with a name
    With self.valueChanged on can connect a pyqt slot with the
    combobox pyqtSignal.
    """

    def __init__(self, name, options, slot=None, default=None):
        super(ComboBoxWidget, self).__init__()
        self.activated = pyqtSignal()

        # ComboBox itself
        self.combobox = QtWidgets.QComboBox()
        self.combobox.orientationCombo = PyQt5.QtWidgets.QComboBox()
        self.combobox.setFixedWidth(220)

        # Label
        self.label = QtWidgets.QLabel()
        self.label.setText(name + ": ")

        self.SingleCheckBoxLayout = QBoxLayout(QBoxLayout.LeftToRight)
        self.SingleCheckBoxLayout.addWidget(self.label)
        self.SingleCheckBoxLayout.addWidget(self.combobox, Qt.AlignRight)
        self.setLayout(self.SingleCheckBoxLayout)
        self.setFixedHeight(70)
        self.setFlat(True)

        # options
        for i in options:
            self.add_item(i)

        if default is not None:
            index = self.combobox.findText(default)
            if index != -1:
                self.combobox.setCurrentIndex(index)

        if slot is not None:
            self.combobox.activated.connect(slot)


    def add_item(self, option, image=None):
        """

        Args:
            | *option*: A string option refers to an entry which can be selected in the combobox later.
            | *image*: An optional icon that can be shown combobox.
        """
        if image is None:
            self.combobox.addItem(option)
        else:
            self.combobox.addItem(QIcon(image), option)
开发者ID:andreasfirczynski,项目名称:NetworkExtractionFromImages,代码行数:52,代码来源:main_controller.py

示例6: __init__

 def __init__(self, actions=None, parent=None,
              direction=QBoxLayout.LeftToRight):
     QWidget.__init__(self, parent)
     self.actions = []
     self.buttons = []
     layout = QBoxLayout(direction)
     layout.setContentsMargins(0, 0, 0, 0)
     self.setContentsMargins(0, 0, 0, 0)
     self.setLayout(layout)
     if actions is not None:
         for action in actions:
             self.addAction(action)
     self.setLayout(layout)
开发者ID:srio,项目名称:Orange-XOPPY,代码行数:13,代码来源:itemmodels.py

示例7: __init__

    def __init__(self, name, options, slot=None, default=None):
        super(ComboBoxWidget, self).__init__()
        self.activated = pyqtSignal()

        # ComboBox itself
        self.combobox = QtWidgets.QComboBox()
        self.combobox.orientationCombo = PyQt5.QtWidgets.QComboBox()
        self.combobox.setFixedWidth(220)

        # Label
        self.label = QtWidgets.QLabel()
        self.label.setText(name + ": ")

        self.SingleCheckBoxLayout = QBoxLayout(QBoxLayout.LeftToRight)
        self.SingleCheckBoxLayout.addWidget(self.label)
        self.SingleCheckBoxLayout.addWidget(self.combobox, Qt.AlignRight)
        self.setLayout(self.SingleCheckBoxLayout)
        self.setFixedHeight(70)
        self.setFlat(True)

        # options
        for i in options:
            self.add_item(i)

        if default is not None:
            index = self.combobox.findText(default)
            if index != -1:
                self.combobox.setCurrentIndex(index)

        if slot is not None:
            self.combobox.activated.connect(slot)
开发者ID:andreasfirczynski,项目名称:NetworkExtractionFromImages,代码行数:31,代码来源:main_controller.py

示例8: __init__

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

        self.GroupOfImagesLayout = QBoxLayout(QBoxLayout.TopToBottom)
        GroupOfImages.setFixedHeight(self, 300)
        GroupOfImages.setFixedWidth(self, 300)
        self.height = 300
开发者ID:andreasfirczynski,项目名称:NetworkExtractionFromImages,代码行数:7,代码来源:ViewImage.py

示例9: __init__

    def __init__(self, parent=None):
        super(EditView, self).__init__(parent)
        self._layout = QBoxLayout(QBoxLayout.LeftToRight)
        self.setLayout(self._layout)
        self.setWindowTitle('Edit configuration')
        
        self._configurationTreeWidget = TreeWidget()
        self._configurationTreeWidget.setColumnCount(2)
        self._configurationTreeWidget.setHeaderLabels(["Configuration name", "Print amount"])
        self._materialTreeWidget = TreeWidget()
        self._materialTreeWidget.setColumnCount(2)
        self._materialTreeWidget.setHeaderLabels(["Material name", "Print amount"])
        self._initialize_material_model()
        
        self._currentConfiguration = None # type: Configuration
        
        config_widget = QWidget()
        self._configLayout = QBoxLayout(QBoxLayout.TopToBottom)
        self._nameField = QLineEdit()
        self._nameField.setEnabled(False)
        name_form_layout = QFormLayout()
        name_form_layout.addRow('Name:', self._nameField)
        self._configLayout.addLayout(name_form_layout)
        self._configLayout.addWidget(QLabel('List of configurations'))
        self._configLayout.addWidget(self._configurationTreeWidget)
        config_widget.setLayout(self._configLayout)
        
        self._saveButton = QPushButton("Save")
        material_widget = QWidget()
        self._materialLayout = QBoxLayout(QBoxLayout.TopToBottom)
        self._materialLayout.addWidget(self._saveButton)
        self._materialLayout.addWidget(QLabel('List of materials'))
        self._materialLayout.addWidget(self._materialTreeWidget)
        material_widget.setLayout(self._materialLayout)
        
        self._layout.addWidget(config_widget)
        self._layout.addWidget(material_widget)

        # add event listener for selection change
        self._configurationTreeWidget.setEditTriggers(self._configurationTreeWidget.NoEditTriggers)
        self._materialTreeWidget.setEditTriggers(self._materialTreeWidget.NoEditTriggers)
        self._configurationTreeWidget.itemDoubleClicked.connect(self._check_edit_configuration)
        self._materialTreeWidget.itemDoubleClicked.connect(self._check_edit_material)
        self._materialTreeWidget.expanded.connect(self._resize_columns)
        self._materialTreeWidget.collapsed.connect(self._resize_columns)
        self._materialTreeWidget.itemChecked.connect(self._on_toggle)
        self._saveButton.clicked.connect(self._save)
开发者ID:frmwrk123,项目名称:oeprint,代码行数:47,代码来源:edit_view.py

示例10: __init__

    def __init__(self):
        super(Window, self).__init__()
        global current_state
        current_state = dict(screen_data)

        self.createControls()
        self.createCommandBox()

        self.brightnessSliders = SlidersGroup(self.commandBox)

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

        layout = QBoxLayout(QBoxLayout.TopToBottom)
        layout.addWidget(self.stackedWidget)
        layout.addWidget(self.commandBoxGroup)
        layout.addWidget(self.controlsGroup)
        self.setLayout(layout)

        self.setWindowTitle("Brightness editor")
        self.resize(850, 500)

        command = "# get display names and brightness values\n" + \
                  get_brightness_command                 + "\n" + \
                  "# results (formatted): " + str(screen_data)
        if primary != None:
            command += " primary: " + screen_data[primary][0]
        self.commandBox.document().setPlainText(command)
开发者ID:VelizarHristov,项目名称:xrandr-dimmer,代码行数:28,代码来源:__init__.py

示例11: __init__

    def __init__(self, orientation, title, parent=None):
        super(SlidersGroup, self).__init__(title, parent)

        self.slider = QSlider(orientation)
        self.slider.setFocusPolicy(Qt.StrongFocus)
        self.slider.setTickPosition(QSlider.TicksBothSides)
        self.slider.setTickInterval(10)
        self.slider.setSingleStep(1)

        self.scrollBar = QScrollBar(orientation)
        self.scrollBar.setFocusPolicy(Qt.StrongFocus)

        self.dial = QDial()
        self.dial.setFocusPolicy(Qt.StrongFocus)

        self.slider.valueChanged.connect(self.scrollBar.setValue)
        self.scrollBar.valueChanged.connect(self.dial.setValue)
        self.dial.valueChanged.connect(self.slider.setValue)
        self.dial.valueChanged.connect(self.valueChanged)

        if orientation == Qt.Horizontal:
            direction = QBoxLayout.TopToBottom
        else:
            direction = QBoxLayout.LeftToRight

        slidersLayout = QBoxLayout(direction)
        slidersLayout.addWidget(self.slider)
        slidersLayout.addWidget(self.scrollBar)
        slidersLayout.addWidget(self.dial)
        self.setLayout(slidersLayout)    
开发者ID:death-finger,项目名称:Scripts,代码行数:30,代码来源:sliders.py

示例12: __init__

  def __init__(self, *args, **kwargs):
    # set parent
    super().__init__(kwargs['main_window'])

    self.setModal(True)
    self.show()
    
    self.setWindowTitle("New Course")

    self.setFixedSize(400, 150)

    # main widget
    #main_widget = QWidget()
    main_layout = QBoxLayout(QBoxLayout.TopToBottom)

    # form widget
    form_widget = QWidget()
    form_layout = QFormLayout()
    form_layout.setFormAlignment(QtCore.Qt.AlignLeft)
    new_course_label = QLabel("Course Name:")
    new_course_entry = CustomLineEdit(default_entry="<Enter course name>")
    new_course_entry.setFixedWidth(230)
    form_layout.addRow(new_course_label, new_course_entry)
    form_widget.setLayout(form_layout)

    # action buttons
    action_widget = QWidget()
    add_course_button = QPushButton("Add Course")
    cancel_button = QPushButton("Cancel")
    action_layout = QBoxLayout(QBoxLayout.LeftToRight)
    action_layout.addWidget(cancel_button)
    action_layout.addWidget(add_course_button)
    action_widget.setLayout(action_layout)
    action_widget.setTabOrder(add_course_button, cancel_button)

    # add widgets
    main_layout.addWidget(form_widget)
    main_layout.addWidget(action_widget)
    self.setLayout(main_layout)

    new_course_entry.setFocus()
    new_course_entry.selectAll()
开发者ID:schmudu,项目名称:gradebook,代码行数:42,代码来源:new_course_dialog.py

示例13: GroupOfImages

class GroupOfImages(QGroupBox):
    def __init__(self):
        super(GroupOfImages, self).__init__()

        self.GroupOfImagesLayout = QBoxLayout(QBoxLayout.TopToBottom)
        GroupOfImages.setFixedHeight(self, 300)
        GroupOfImages.setFixedWidth(self, 300)
        self.height = 300

    def addImage(self, image):
        self.GroupOfImagesLayout.addWidget(image)
        self.height += 300
        GroupOfImages.setFixedHeight(self, self.height + 300)
        self.setLayout(self.GroupOfImagesLayout)

    def removeImage(self, image):
        self.GroupOfImagesLayout.removeWidget(image)
        self.setLayout(self.GroupOfImagesLayout)

    def refreshView(self):
        self.setLayout(self.GroupOfImagesLayout)
开发者ID:andreasfirczynski,项目名称:NetworkExtractionFromImages,代码行数:21,代码来源:ViewImage.py

示例14: install_layout_for_widget

def install_layout_for_widget(widget, orientation=None, margins=None, spacing=None):
    """
    Installs a layout to widget, if it does not have it already.
    :param widget: target widget
    :param orientation: Qt.Vertical (default) / Qt.Horizontal
    :param margins: layout margins = (11, 11, 11, 11) from Qt docs, style dependent
    :param spacing: spacing between items in layout
    :return: None
    """
    if widget.layout() is not None:
        logger.debug('Widget {0} already has a layout, skipping'.format(widget.windowTitle()))
        return  # already has a layout
    direction = QBoxLayout.TopToBottom
    if orientation == Qt.Horizontal:
        direction = QBoxLayout.LeftToRight
    l = QBoxLayout(direction)
    if margins is not None:
        l.setContentsMargins(margins[0], margins[1], margins[2], margins[3])
    if spacing is not None:
        l.setSpacing(spacing)
    widget.setLayout(l)
开发者ID:minlexx,项目名称:xnovacmd,代码行数:21,代码来源:widget_utils.py

示例15: __init__

	def __init__(self, message, title):
		super(ErrorMessage, self).__init__()
		self.message = message

		# self.setWindowTitle(title)
		self.setStyleSheet(style.style_loader.stylesheet)

		self.label = QLabel(str(self.message), self)

		self.label_widget = QWidget(self)
		label_layout = QBoxLayout(QBoxLayout.LeftToRight)
		label_layout.addWidget(self.label)
		self.label_widget.setLayout(label_layout)

		self.submit_btn = QPushButton('OK', self)
		self.submit_btn.clicked.connect(self.submit)

		self.submit_btn_widget = QWidget(self)
		submit_btn_layout = QBoxLayout(QBoxLayout.LeftToRight)
		submit_btn_layout.addWidget(self.submit_btn)
		self.submit_btn_widget.setLayout(submit_btn_layout)

		layout = QFormLayout()
		layout.addRow(self.label_widget)
		layout.addRow(self.submit_btn_widget)
		self.setLayout(layout)

		self.show()
		self.setFixedHeight(self.height())
		self.setFixedWidth(self.width())
		self.close()
开发者ID:zlohner,项目名称:TournamentOrganizer,代码行数:31,代码来源:error_message.py


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