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


Python QVBoxLayout.setStretch方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import setStretch [as 别名]
    def __init__(self, parentWidget):
        QWidget.__init__(self, parentWidget)

        self.formatManager = FormatManager()
        self.formatManager.loadFormats()

        self.editView = StylableTextEdit(self, self.formatManager)
        self.editView.navigate.connect(self.navigate)
        self.editView.objectSelectionChanged.connect(self.objectSelectionChanged)

        toolbar = QWidget(self)
        layout = QHBoxLayout()
        layout.setContentsMargins(0,0,0,0)
        toolbar.setLayout(layout)

        self.actionsSelector = ActionSelector(self)
        layout.addWidget(self.actionsSelector)

        self.textFormatSelector = TextStyleSelector(self)
        self.textFormatSelector.styleChanged.connect(self.editView.applyTextFormat)
        self.editView.updateCharFormat.connect(self.textFormatSelector.setCurrentStyle)
        layout.addWidget(self.textFormatSelector)

        self.styleSelector = BlockStyleSelector(self)
        self.styleSelector.styleChanged.connect(self.editView.applyBlockStyle)
        self.styleSelector.indentLess.connect(self.editView.indentLess)
        self.styleSelector.indentMore.connect(self.editView.indentMore)
        self.styleSelector.insertTable.connect(self.insertTable)
        self.editView.updateBlockFormat.connect(self.styleSelector.setCurrentStyle)
        layout.addWidget(self.styleSelector)

        searchMarker = self.formatManager.getFormat( ('searchMarker', None, None) )
        self.findWidget = FindWidget(self, searchMarker.getCharFormat(), self.editView)
        self.findWidget.hide()

        self.editMathWidget = MathEditWidget(self)
        self.editMathWidget.apply.connect(self.applyMathFormula)
        self.editMathWidget.hide()

        #horizontalSpacer = QSpacerItem(0, 0) # 40, 20) # , QSizePolicy.Expanding, QSizePolicy.Minimum)
        #layout.addItem(horizontalSpacer)

        hLayout = QVBoxLayout(self)
        hLayout.setContentsMargins(0, 0, 0, 0)
        hLayout.addWidget(toolbar)
        hLayout.addWidget(self.findWidget)
        hLayout.addWidget(self.editView)
        hLayout.addWidget(self.editMathWidget)

        # The toolbar should take the minimum space and the edit view the remaining space
        hLayout.setStretch(0, 0)
        hLayout.setStretch(1, 0)
        hLayout.setStretch(2, 1)
        hLayout.setStretch(3, 0.1)
开发者ID:afester,项目名称:CodeSamples,代码行数:56,代码来源:EditorWidget.py

示例2: initWindow

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import setStretch [as 别名]
    def initWindow(self):
        QToolTip.setFont(QFont('SansSerif', 10))
        # main layout
        frameWidget = QWidget()
        mainWidget = QSplitter(Qt.Horizontal)
        frameLayout = QVBoxLayout()
        self.settingWidget = QWidget()
        self.settingWidget.setProperty("class","settingWidget")
        self.receiveSendWidget = QSplitter(Qt.Vertical)
        self.functionalWiget = QWidget()
        settingLayout = QVBoxLayout()
        sendReceiveLayout = QVBoxLayout()
        sendFunctionalLayout = QVBoxLayout()
        mainLayout = QHBoxLayout()
        self.settingWidget.setLayout(settingLayout)
        self.receiveSendWidget.setLayout(sendReceiveLayout)
        self.functionalWiget.setLayout(sendFunctionalLayout)
        mainLayout.addWidget(self.settingWidget)
        mainLayout.addWidget(self.receiveSendWidget)
        mainLayout.addWidget(self.functionalWiget)
        mainLayout.setStretch(0,2)
        mainLayout.setStretch(1, 6)
        mainLayout.setStretch(2, 2)
        menuLayout = QHBoxLayout()
        mainWidget.setLayout(mainLayout)
        frameLayout.addLayout(menuLayout)
        frameLayout.addWidget(mainWidget)
        frameWidget.setLayout(frameLayout)
        self.setCentralWidget(frameWidget)

        # option layout
        self.settingsButton = QPushButton()
        self.skinButton = QPushButton("")
        self.waveButton = QPushButton("")
        self.aboutButton = QPushButton()
        self.functionalButton = QPushButton()
        self.encodingCombobox = ComboBox()
        self.encodingCombobox.addItem("ASCII")
        self.encodingCombobox.addItem("UTF-8")
        self.encodingCombobox.addItem("UTF-16")
        self.encodingCombobox.addItem("GBK")
        self.encodingCombobox.addItem("GB2312")
        self.encodingCombobox.addItem("GB18030")
        self.settingsButton.setProperty("class", "menuItem1")
        self.skinButton.setProperty("class", "menuItem2")
        self.aboutButton.setProperty("class", "menuItem3")
        self.functionalButton.setProperty("class", "menuItem4")
        self.waveButton.setProperty("class", "menuItem5")
        self.settingsButton.setObjectName("menuItem")
        self.skinButton.setObjectName("menuItem")
        self.aboutButton.setObjectName("menuItem")
        self.functionalButton.setObjectName("menuItem")
        self.waveButton.setObjectName("menuItem")
        menuLayout.addWidget(self.settingsButton)
        menuLayout.addWidget(self.skinButton)
        menuLayout.addWidget(self.waveButton)
        menuLayout.addWidget(self.aboutButton)
        menuLayout.addStretch(0)
        menuLayout.addWidget(self.encodingCombobox)
        menuLayout.addWidget(self.functionalButton)


        # widgets receive and send area
        self.receiveArea = QTextEdit()
        self.sendArea = QTextEdit()
        self.clearReceiveButtion = QPushButton(parameters.strClearReceive)
        self.sendButtion = QPushButton(parameters.strSend)
        self.sendHistory = ComboBox()
        sendWidget = QWidget()
        sendAreaWidgetsLayout = QHBoxLayout()
        sendWidget.setLayout(sendAreaWidgetsLayout)
        buttonLayout = QVBoxLayout()
        buttonLayout.addWidget(self.clearReceiveButtion)
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.sendButtion)
        sendAreaWidgetsLayout.addWidget(self.sendArea)
        sendAreaWidgetsLayout.addLayout(buttonLayout)
        sendReceiveLayout.addWidget(self.receiveArea)
        sendReceiveLayout.addWidget(sendWidget)
        sendReceiveLayout.addWidget(self.sendHistory)
        sendReceiveLayout.setStretch(0, 7)
        sendReceiveLayout.setStretch(1, 2)
        sendReceiveLayout.setStretch(2, 1)

        # widgets serial settings
        serialSettingsGroupBox = QGroupBox(parameters.strSerialSettings)
        serialSettingsLayout = QGridLayout()
        serialReceiveSettingsLayout = QGridLayout()
        serialSendSettingsLayout = QGridLayout()
        serialPortLabek = QLabel(parameters.strSerialPort)
        serailBaudrateLabel = QLabel(parameters.strSerialBaudrate)
        serailBytesLabel = QLabel(parameters.strSerialBytes)
        serailParityLabel = QLabel(parameters.strSerialParity)
        serailStopbitsLabel = QLabel(parameters.strSerialStopbits)
        self.serialPortCombobox = ComboBox()
        self.serailBaudrateCombobox = ComboBox()
        self.serailBaudrateCombobox.addItem("9600")
        self.serailBaudrateCombobox.addItem("19200")
        self.serailBaudrateCombobox.addItem("38400")
        self.serailBaudrateCombobox.addItem("57600")
#.........这里部分代码省略.........
开发者ID:coolsnake,项目名称:COMTool,代码行数:103,代码来源:Main.py

示例3: Appearance

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import setStretch [as 别名]
class Appearance(SettingsSection):

    Name = 'Appearance'

    DEFAULT_STYLE = 'background: rgb(70, 70, 70);' + \
                    'border: 1 solid rgb(0, 0, 0);' + \
                    'border-radius: 6;'

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

        self.verticalLayout = QVBoxLayout(self)

        self.textEditGroup = QGroupBox(self)
        self.horizontalLayout = QHBoxLayout(self.textEditGroup)

        self.textEdit = QTextEdit(self.textEditGroup)
        self.horizontalLayout.addWidget(self.textEdit)

        self.verticalLayout.addWidget(self.textEditGroup)

        self.fontSizeGroup = QGroupBox(self)
        self.horizontalLayout_1 = QHBoxLayout(self.fontSizeGroup)

        self.fontSizeSpin = QSpinBox(self.fontSizeGroup)
        self.horizontalLayout_1.addWidget(self.fontSizeSpin)

        self.verticalLayout.addWidget(self.fontSizeGroup)

        self.colorGroup = QGroupBox(self)
        self.horizontalLayout_2 = QHBoxLayout(self.colorGroup)

        self.colorBButton = QPushButton(self.colorGroup)
        self.horizontalLayout_2.addWidget(self.colorBButton)

        self.colorFButton = QPushButton(self.colorGroup)
        self.horizontalLayout_2.addWidget(self.colorFButton)

        self.verticalLayout.addWidget(self.colorGroup)

        self.previewGroup = QGroupBox(self)
        self.horizontalLayout_3 = QHBoxLayout(self.previewGroup)

        self.beforeLabel = QLabel(self.previewGroup)
        self.beforeLabel.setStyleSheet(self.DEFAULT_STYLE)
        self.beforeLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.horizontalLayout_3.addWidget(self.beforeLabel)

        self.nowLabel = QLabel(self.previewGroup)
        self.nowLabel.setStyleSheet(self.DEFAULT_STYLE)
        self.nowLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.horizontalLayout_3.addWidget(self.nowLabel)

        self.verticalLayout.addWidget(self.previewGroup)

        self.textEdit.textChanged.connect(self.changeText)
        self.fontSizeSpin.valueChanged.connect(self.updatePreview)
        self.colorBButton.clicked.connect(self.changeBColor)
        self.colorFButton.clicked.connect(self.changeFColor)

        self.warning = QLabel(self)
        self.warning.setText("The real appearance depends on the layout")
        self.warning.setAlignment(QtCore.Qt.AlignCenter)
        self.warning.setStyleSheet("color: red; font-weight: bold")

        self.verticalLayout.addWidget(self.warning)

        self.verticalLayout.setStretch(0, 3)
        self.verticalLayout.setStretch(1, 1)
        self.verticalLayout.setStretch(2, 1)
        self.verticalLayout.setStretch(3, 2)
        self.verticalLayout.setStretch(4, 1)

        self.retranslateUi()

        self.bColor = 'rgb(0,0,0)'
        self.fColor = 'rgb(177,177,177)'
        self.fontSizeSpin.setValue(11)

    def retranslateUi(self):
        self.textEditGroup.setTitle("Shown Text")
        self.textEdit.setText("Empty")
        self.fontSizeGroup.setTitle("Set Font Size")
        self.colorGroup.setTitle("Color")
        self.colorBButton.setText("Select background color")
        self.colorFButton.setText("Select font color")
        self.previewGroup.setTitle("Preview")
        self.beforeLabel.setText("Before")
        self.nowLabel.setText("After")

    def enable_check(self, enable):
        self.textEditGroup.setCheckable(enable)
        self.textEditGroup.setChecked(False)

        self.fontSizeGroup.setCheckable(enable)
        self.fontSizeGroup.setChecked(False)

        self.colorGroup.setCheckable(enable)
        self.colorGroup.setChecked(False)

#.........这里部分代码省略.........
开发者ID:tornel,项目名称:linux-show-player,代码行数:103,代码来源:cue_appearance.py


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