我们从Python开源项目中,提取了以下28个代码示例,用于说明如何使用PyQt5.QtCore.Qt.Vertical()。
def splitter_setting(self): """ set splitter :return: """ if self.splitter: self.splitter = None self.splitter = QSplitter(Qt.Vertical) self.splitter.setHandleWidth(1) # add "case_widget" and "log_area" to splitter self.splitter.addWidget(self.case_widget) self.splitter.addWidget(self.log_area) # set the initial scale: 4:1 self.splitter.setStretchFactor(0, 4) self.splitter.setStretchFactor(1, 1) self.case_table_layout.addWidget(self.splitter)
def doLayout(self, rect, testOnly): x = rect.x() y = rect.y() lineHeight = 0 for item in self.itemList: wid = item.widget() spaceX = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Horizontal) spaceY = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Vertical) nextX = x + item.sizeHint().width() + spaceX if nextX - spaceX > rect.right() and lineHeight > 0: x = rect.x() y = y + lineHeight + spaceY nextX = x + item.sizeHint().width() + spaceX lineHeight = 0 if not testOnly: item.setGeometry(QRect(QPoint(x, y), item.sizeHint())) x = nextX lineHeight = max(lineHeight, item.sizeHint().height()) return y + lineHeight - rect.y()
def __init__(self, parent): super(PercentSlider, self).__init__(parent) self._slider = QSlider(Qt.Vertical, self) self._slider.setMinimum(-100) self._slider.setMaximum(100) self._slider.setValue(0) self._slider.setTickInterval(100) self._slider.setTickPosition(QSlider.TicksBothSides) self._slider.valueChanged.connect(lambda: self._spinbox.setValue(self._slider.value())) self._spinbox = QSpinBox(self) self._spinbox.setMinimum(-100) self._spinbox.setMaximum(100) self._spinbox.setValue(0) self._spinbox.valueChanged.connect(lambda: self._slider.setValue(self._spinbox.value())) self._zero_button = make_icon_button('hand-stop-o', 'Zero setpoint', self, on_clicked=self.zero) layout = QVBoxLayout(self) sub_layout = QHBoxLayout(self) sub_layout.addStretch() sub_layout.addWidget(self._slider) sub_layout.addStretch() layout.addLayout(sub_layout) layout.addWidget(self._spinbox) layout.addWidget(self._zero_button) self.setLayout(layout) self.setMinimumHeight(400)
def createSlider(self): slider = QSlider(Qt.Vertical) slider.setRange(0, 360 * 16) slider.setSingleStep(16) slider.setPageStep(15 * 16) slider.setTickInterval(15 * 16) slider.setTickPosition(QSlider.TicksRight) return slider
def headerData(self, index, orientation, role=None): if role == Qt.DisplayRole: if orientation == Qt.Horizontal: columns = self.get_headers() return _(columns[index]) if orientation == Qt.Vertical: return str(index+1)
def __init__(self,path,notebook): QWidget.__init__(self) self.path = path self.notebook = notebook self.lo = QVBoxLayout() self.t = QTextEdit() self.t.setReadOnly(True) self.setLayout(self.lo) self.list = QListWidget() self.entries = findAllCalenderEntries(config.notespath) self.entries= sorted(self.entries,key=lambda x: x[0]) self.split = QSplitter(Qt.Vertical) self.selector = QSplitter() self.cal = QCalendarWidget() now = datetime.datetime.now() self.cal.setSelectedDate(QtCore.QDate.currentDate()) self.cal.setSizePolicy(QSizePolicy.Maximum,QSizePolicy.Maximum) self.selector.addWidget(self.cal) self.selector.addWidget(self.list) self.lo.addWidget(self.split) self.split.addWidget(self.selector) self.split.addWidget(self.t) def f(y=None,m=None): z = datetime.datetime(year=self.cal.yearShown(),month=self.cal.monthShown(),day=1) e = z+datetime.timedelta(days=31) try: self.populate(z,e) except: raise self.cal.currentPageChanged.connect(f) self.list.itemDoubleClicked.connect(self.onDoubleClick) self.list.itemClicked.connect(self.onClick) f()
def __init__(self): super(FrameCapture, self).__init__() self._percent = 0 self._page = QWebPage() self._page.mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) self._page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) self._page.loadProgress.connect(self.printProgress) self._page.loadFinished.connect(self.saveResult)
def __init__(self, tableName, parent=None): super(TableEditor, self).__init__(parent) self.model = QSqlTableModel(self) self.model.setTable(tableName) self.model.setEditStrategy(QSqlTableModel.OnManualSubmit) self.model.select() self.model.setHeaderData(0, Qt.Horizontal, "ID") self.model.setHeaderData(1, Qt.Horizontal, "First name") self.model.setHeaderData(2, Qt.Horizontal, "Last name") view = QTableView() view.setModel(self.model) submitButton = QPushButton("Submit") submitButton.setDefault(True) revertButton = QPushButton("&Revert") quitButton = QPushButton("Quit") buttonBox = QDialogButtonBox(Qt.Vertical) buttonBox.addButton(submitButton, QDialogButtonBox.ActionRole) buttonBox.addButton(revertButton, QDialogButtonBox.ActionRole) buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole) submitButton.clicked.connect(self.submit) revertButton.clicked.connect(self.model.revertAll) quitButton.clicked.connect(self.close) mainLayout = QHBoxLayout() mainLayout.addWidget(view) mainLayout.addWidget(buttonBox) self.setLayout(mainLayout) self.setWindowTitle("Cached Table")
def headerData(self, section: int, orientation, role=Qt.DisplayRole): if orientation == Qt.Vertical: if role == Qt.DisplayRole: return self.vertical_header_text[section] elif role == Qt.BackgroundColorRole: return self.vertical_header_colors[section] elif role == Qt.TextColorRole: color = self.vertical_header_colors[section] if color: red, green, blue = color.red(), color.green(), color.blue() return QColor("black") if (red * 0.299 + green * 0.587 + blue * 0.114) > 186 else QColor("white") else: return None return super().headerData(section, orientation, role)
def resize_vertical_header(self): num_rows = self.model().rowCount() if self.isVisible() and num_rows > 0: hd = self.model().headerData max_len = np.max([len(str(hd(i, Qt.Vertical, Qt.DisplayRole))) for i in range(num_rows)]) w = (self.font().pointSize() + 2) * max_len # https://github.com/jopohl/urh/issues/182 rh = self.verticalHeader().defaultSectionSize() for i in range(num_rows): self.verticalHeader().resizeSection(i, w) self.setRowHeight(i, rh) if i % 10 == 0: QApplication.instance().processEvents()
def __init__(self,parent): QToolBar.__init__(self) #aaa=self.readStyleSheet(os.path.join(get_css_path(),"menu.css")) #aaa=str(aaa,'utf-8') #self.setStyleSheet(aaa) self.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) self.setOrientation(Qt.Vertical) #self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint|Qt.WindowStaysOnTopHint) self.setIconSize(QSize(42, 42)) self.configure_configwindow = QAction(QIcon_load("help"), _("Help window"), self) self.addAction(self.configure_configwindow) self.configure_configwindow = QAction(QIcon_load("help"), _("Manual"), self) self.addAction(self.configure_configwindow) self.configure_configwindow = QAction(QIcon_load("help"), _("License"), self) self.addAction(self.configure_configwindow) self.configure_configwindow = QAction(QIcon_load("help"), _("Youtube"), self) self.addAction(self.configure_configwindow) self.configure_configwindow = QAction(QIcon_load("help"), _("Citing the model"), self) self.addAction(self.configure_configwindow) self.configure_configwindow = QAction(QIcon_load("help"), _("About"), self) self.addAction(self.configure_configwindow) l=self.layout() for i in range(0,l.count()): l.itemAt(i).setAlignment(Qt.AlignLeft) self.installEventFilter(self) self.setWindowFlags(Qt.Popup) self.move(self.mapFromGlobal(QCursor.pos()))
def __init__(self): QWidget.__init__(self) edit_boxes=QWidget() vbox=QVBoxLayout() self.lumo=equation_editor("lumo0.inp","LUMO") vbox.addWidget(self.lumo) self.homo=equation_editor("homo0.inp","HOMO") vbox.addWidget(self.homo) edit_boxes.setLayout(vbox) hbox=QHBoxLayout() toolbar=QToolBar() toolbar.setIconSize(QSize(48, 48)) toolbar.setOrientation(Qt.Vertical) add = QAction(QIcon_load("document-save-as"), _("Save"), self) add.triggered.connect(self.callback_save) toolbar.addAction(add) hbox.addWidget(toolbar) self.LUMO_fig = Figure(figsize=(5,4), dpi=100) self.draw_graph_lumo() self.canvas_lumo = FigureCanvas(self.LUMO_fig) self.canvas_lumo.figure.patch.set_facecolor('white') self.LUMO_fig.tight_layout(pad=0.5) hbox.addWidget(self.canvas_lumo) hbox.addWidget(edit_boxes) self.setLayout(hbox) self.lumo.changed.connect(self.update_graph) self.homo.changed.connect(self.update_graph)
def __init__(self, parent=None): super(FindDialog, self).__init__(parent) label = QLabel("Find &what:") lineEdit = QLineEdit() label.setBuddy(lineEdit) caseCheckBox = QCheckBox("Match &case") fromStartCheckBox = QCheckBox("Search from &start") fromStartCheckBox.setChecked(True) findButton = QPushButton("&Find") findButton.setDefault(True) moreButton = QPushButton("&More") moreButton.setCheckable(True) moreButton.setAutoDefault(False) extension = QWidget() wholeWordsCheckBox = QCheckBox("&Whole words") backwardCheckBox = QCheckBox("Search &backward") searchSelectionCheckBox = QCheckBox("Search se&lection") buttonBox = QDialogButtonBox(Qt.Vertical) buttonBox.addButton(findButton, QDialogButtonBox.ActionRole) buttonBox.addButton(moreButton, QDialogButtonBox.ActionRole) moreButton.toggled.connect(extension.setVisible) extensionLayout = QVBoxLayout() extensionLayout.setContentsMargins(0, 0, 0, 0) extensionLayout.addWidget(wholeWordsCheckBox) extensionLayout.addWidget(backwardCheckBox) extensionLayout.addWidget(searchSelectionCheckBox) extension.setLayout(extensionLayout) topLeftLayout = QHBoxLayout() topLeftLayout.addWidget(label) topLeftLayout.addWidget(lineEdit) leftLayout = QVBoxLayout() leftLayout.addLayout(topLeftLayout) leftLayout.addWidget(caseCheckBox) leftLayout.addWidget(fromStartCheckBox) mainLayout = QGridLayout() mainLayout.setSizeConstraint(QLayout.SetFixedSize) mainLayout.addLayout(leftLayout, 0, 0) mainLayout.addWidget(buttonBox, 0, 1) mainLayout.addWidget(extension, 1, 0, 1, 2) mainLayout.setRowStretch(2, 1) self.setLayout(mainLayout) self.setWindowTitle("Extension") extension.hide()
def createControls(self, title): self.controlsGroup = QGroupBox(title) minimumLabel = QLabel("Minimum value:") maximumLabel = QLabel("Maximum value:") valueLabel = QLabel("Current value:") invertedAppearance = QCheckBox("Inverted appearance") invertedKeyBindings = QCheckBox("Inverted key bindings") self.minimumSpinBox = QSpinBox() self.minimumSpinBox.setRange(-100, 100) self.minimumSpinBox.setSingleStep(1) self.maximumSpinBox = QSpinBox() self.maximumSpinBox.setRange(-100, 100) self.maximumSpinBox.setSingleStep(1) self.valueSpinBox = QSpinBox() self.valueSpinBox.setRange(-100, 100) self.valueSpinBox.setSingleStep(1) orientationCombo = QComboBox() orientationCombo.addItem("Horizontal slider-like widgets") orientationCombo.addItem("Vertical slider-like widgets") orientationCombo.activated.connect(self.stackedWidget.setCurrentIndex) self.minimumSpinBox.valueChanged.connect(self.horizontalSliders.setMinimum) self.minimumSpinBox.valueChanged.connect(self.verticalSliders.setMinimum) self.maximumSpinBox.valueChanged.connect(self.horizontalSliders.setMaximum) self.maximumSpinBox.valueChanged.connect(self.verticalSliders.setMaximum) invertedAppearance.toggled.connect(self.horizontalSliders.invertAppearance) invertedAppearance.toggled.connect(self.verticalSliders.invertAppearance) invertedKeyBindings.toggled.connect(self.horizontalSliders.invertKeyBindings) invertedKeyBindings.toggled.connect(self.verticalSliders.invertKeyBindings) controlsLayout = QGridLayout() controlsLayout.addWidget(minimumLabel, 0, 0) controlsLayout.addWidget(maximumLabel, 1, 0) controlsLayout.addWidget(valueLabel, 2, 0) controlsLayout.addWidget(self.minimumSpinBox, 0, 1) controlsLayout.addWidget(self.maximumSpinBox, 1, 1) controlsLayout.addWidget(self.valueSpinBox, 2, 1) controlsLayout.addWidget(invertedAppearance, 0, 2) controlsLayout.addWidget(invertedKeyBindings, 1, 2) controlsLayout.addWidget(orientationCombo, 3, 0, 1, 3) self.controlsGroup.setLayout(controlsLayout)