我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtWidgets.QVBoxLayout()。
def PopulateForm(self): layout = QVBoxLayout() label = QtWidgets.QLabel() label.setText("Notes about sample %s" % idc.GetInputMD5()) self.editor = QtWidgets.QTextEdit() self.editor.setFontFamily(self.skel_settings.notepad_font_name) self.editor.setFontPointSize(self.skel_settings.notepad_font_size) text = self.skel_conn.get_abstract() self.editor.setPlainText(text) # editor.setAutoFormatting(QtWidgets.QTextEdit.AutoAll) self.editor.textChanged.connect(self._onTextChange) layout.addWidget(label) layout.addWidget(self.editor) self.setLayout(layout)
def __init__(self, link_url: str, dl_path: str, parent=None): super(Downloader, self).__init__(parent) self.parent = parent self.dltool_cmd = find_executable(self.download_cmd) self.download_link = link_url self.download_path = dl_path if self.dltool_cmd.strip(): self.dltool_args = self.dltool_args.format(dl_path=self.download_path, dl_link=self.download_link) self.console = QTextEdit(self.parent) self.console.setWindowTitle('%s Downloader' % qApp.applicationName()) self.proc = QProcess(self.parent) layout = QVBoxLayout() layout.addWidget(self.console) self.setLayout(layout) self.setFixedSize(QSize(400, 300)) else: QMessageBox.critical(self.parent, 'DOWNLOADER ERROR', '<p>The <b>aria2c</b> executable binary could not ' + 'be found in your installation folders. The binary comes packaged with this ' + 'application so it is likely that it was accidentally deleted via human ' + 'intervntion or incorrect file permissions are preventing access to it.</p>' + '<p>You may either download and install <b>aria2</b> manually yourself, ensuring ' + 'its installation location is globally accessible via PATH environmnt variables or ' + 'simply reinstall this application again. If the issue is not resolved then try ' + 'to download the application again incase the orignal you installed already was ' + 'corrupted/broken.', buttons=QMessageBox.Close)
def __init__( self, app, title ): super().__init__( app, title ) self.code_font = self.app.getCodeFont() self.text_edit = QtWidgets.QTextEdit() self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget( self.text_edit ) self.setLayout( self.layout ) self.all_text_formats = {} for style, fg_colour, bg_colour in self.all_style_colours: char_format = QtGui.QTextCharFormat() char_format.setFont( self.code_font ) char_format.setForeground( QtGui.QBrush( QtGui.QColor( str(fg_colour) ) ) ) char_format.setBackground( QtGui.QBrush( QtGui.QColor( str(bg_colour) ) ) ) self.all_text_formats[ style ] = char_format self.text_edit.setReadOnly( True ) em = self.app.fontMetrics().width( 'm' ) ex = self.app.fontMetrics().lineSpacing() self.resize( 130*em, 45*ex )
def __init__(self, name, parent=None): super(Chatter, self).__init__(parent) self.name = name self.text_panel = QtWidgets.QTextEdit() self.text_panel.setReadOnly(True) self.input = QtWidgets.QLineEdit() layout = QtWidgets.QVBoxLayout() layout.addWidget(self.text_panel, 3) layout.addWidget(self.input, 1) self.setLayout(layout) self.setWindowTitle("Chatter") self.input.editingFinished.connect(self.input_changed) self.input.setFocus() self.chattery = nw0.discover("chattery/news") self.responder = FeedbackReader(self.chattery) self.responder.message_received.connect(self.handle_response) self.responder.start()
def __init__(self, parent): super(LCAResultsTab, self).__init__(parent) self.panel = parent # e.g. right panel self.visible = False self.scroll_area = QtWidgets.QScrollArea() self.scroll_widget = QtWidgets.QWidget() self.scroll_widget_layout = QtWidgets.QVBoxLayout() self.scroll_widget.setLayout(self.scroll_widget_layout) self.scroll_area.setWidget(self.scroll_widget) self.scroll_area.setWidgetResizable(True) self.layout = QtWidgets.QVBoxLayout() self.setLayout(self.layout) self.connect_signals()
def __init__(self, parent=None): super().__init__(parent) self.wizard = self.parent() options = ['ecoinvent homepage', 'local 7z-archive', 'local directory with ecospold2 files'] self.radio_buttons = [QtWidgets.QRadioButton(o) for o in options] self.option_box = QtWidgets.QGroupBox('Choose type of database import') box_layout = QtWidgets.QVBoxLayout() for i, button in enumerate(self.radio_buttons): box_layout.addWidget(button) if i == 0: button.setChecked(True) self.option_box.setLayout(box_layout) self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.option_box) self.setLayout(self.layout)
def __init__(self, parent, node): super(NodeMonitorWidget, self).__init__(parent) self.setTitle('Online nodes (double click for more options)') self._node = node self.on_info_window_requested = lambda *_: None self._status_update_timer = QTimer(self) self._status_update_timer.setSingleShot(False) self._status_update_timer.timeout.connect(self._update_status) self._status_update_timer.start(500) self._table = NodeTable(self, node) self._table.info_requested.connect(self._show_info_window) self._monitor_handle = self._table.monitor.add_update_handler(lambda _: self._update_status()) self._status_label = QLabel(self) vbox = QVBoxLayout(self) vbox.addWidget(self._table) vbox.addWidget(self._status_label) self.setLayout(vbox)
def initUI(self): self.tf = 'PlotTextFile.txt' self.createTopLeftGroupBox() self.createTopRightGroupBox() self.createBottomLeftGroupBox() self.createBottomRightGroupBox() topLayout = QHBoxLayout() topLayout.addWidget(self.topLeftGroupBox) topLayout.addWidget(self.topRightGroupBox) bottomLayout = QHBoxLayout() bottomLayout.addWidget(self.bottomLeftGroupBox) bottomLayout.addWidget(self.bottomRightGroupBox) mainLayout = QVBoxLayout() mainLayout.addLayout(topLayout) mainLayout.addLayout(bottomLayout) mainLayout.addStretch(1) self.setLayout(mainLayout) self.show()
def createTopLeftGroupBox(self): self.topLeftGroupBox = QGroupBox("Temperature Sensor") tempLabel = QLabel('Temperature: ') self.tempValLabel = QLabel('NULL') plotButton = QPushButton("Show Plot") plotButton.clicked.connect(self.tempPlot) saveDataButton = QPushButton('Save Data File') saveDataButton.clicked.connect(self.savefile) vbox1 = QVBoxLayout() vbox1.addWidget(tempLabel) vbox1.addWidget(self.tempValLabel) vbox2 = QVBoxLayout() vbox2.addWidget(plotButton) vbox2.addWidget(saveDataButton) layout = QHBoxLayout() layout.addLayout(vbox1) layout.addLayout(vbox2) layout.addStretch(1) self.topLeftGroupBox.setLayout(layout)
def createTopRightGroupBox(self): self.topRightGroupBox = QGroupBox('Heater') heatLabel = QLabel('Target Temperature(C):') heatEntry = QLineEdit() heatEntry.textChanged[str].connect(self.tempOnChanged) heatEntry.setText('41') self.heatButton = QPushButton('Heater ON') self.heatButton.clicked.connect(self.heaterPower) hbox1 = QHBoxLayout() hbox1.addWidget(heatLabel) hbox1.addWidget(heatEntry) hbox2 = QHBoxLayout() hbox2.addWidget(self.heatButton) layout = QVBoxLayout() layout.addLayout(hbox1) layout.addLayout(hbox2) layout.addStretch(1) self.topRightGroupBox.setLayout(layout)
def initUI(self): self.tf = 'PlotTextFile.txt' self.statusbar = 'Ready' self.createTopGroupBox() self.createMidGroupBox() self.createBottomLeftGroupBox() self.createBottomRightGroupBox() topLayout = QVBoxLayout() topLayout.addWidget(self.topGroupBox) topLayout.addWidget(self.midGroupBox) bottomLayout = QHBoxLayout() bottomLayout.addWidget(self.bottomLeftGroupBox) bottomLayout.addWidget(self.bottomRightGroupBox) mainLayout = QVBoxLayout() mainLayout.addLayout(topLayout) mainLayout.addLayout(bottomLayout) mainLayout.addStretch(1) self.setLayout(mainLayout) self.show()
def createBottomLeftGroupBox(self): self.bottomLeftGroupBox = QGroupBox('Sensor Options') captureBtn = QPushButton('Capture Data') captureBtn.clicked.connect(self.captureDataThread) setNormOptionsBtn = QPushButton('Set Normal Options') setNormOptionsBtn.clicked.connect(self.normalSettings) setDarkOptionsBtn = QPushButton('Set Low Light Options') setDarkOptionsBtn.clicked.connect(self.darkSettings) saveBtn = QPushButton('Save Data') saveBtn.clicked.connect(self.saveData) layout = QVBoxLayout() layout.addWidget(captureBtn) layout.addWidget(setNormOptionsBtn) layout.addWidget(setDarkOptionsBtn) layout.addWidget(saveBtn) layout.addStretch(1) self.bottomLeftGroupBox.setLayout(layout)
def layout(self): """ """ main_layout = QW.QVBoxLayout(self) form_layout = QW.QFormLayout() version = pkg_resources.require("pytc-gui")[0].version name_label = QW.QLabel("pytc: GUI") name_font = name_label.font() name_font.setPointSize(20) name_label.setFont(name_font) name_label.setAlignment(Qt.AlignCenter) version_label = QW.QLabel("Version " + version) version_font = version_label.font() version_font.setPointSize(14) version_label.setFont(version_font) version_label.setAlignment(Qt.AlignCenter) author_info = QW.QLabel("Hiranmayi Duvvuri, Mike Harms") author_font = author_info.font() author_font.setPointSize(10) author_info.setFont(author_font) OK_button = QW.QPushButton("OK", self) OK_button.clicked.connect(self.close) main_layout.addWidget(name_label) main_layout.addWidget(version_label) main_layout.addWidget(author_info) main_layout.addWidget(OK_button) self.setWindowTitle("About")
def layout(self): """ Lay out the dialog. """ main_layout = QW.QVBoxLayout(self) test_layout = QW.QHBoxLayout() button_layout = QW.QVBoxLayout() self._fitter_select = QW.QListWidget() self._fitter_select.setSelectionMode(QW.QAbstractItemView.ExtendedSelection) for k,v in self._fit_snapshot_dict.items(): self._fitter_select.addItem(k) self._fitter_select.setFixedSize(150, 100) ftest_button = QW.QPushButton("Perform AIC Test", self) ftest_button.clicked.connect(self.perform_test) add_fit_button = QW.QPushButton("Append New Fit", self) add_fit_button.clicked.connect(self.add_fitter) self._data_out = QW.QTextEdit() self._data_out.setReadOnly(True) self._data_out.setMinimumWidth(400) # add buttons to layout button_layout.addWidget(ftest_button) button_layout.addWidget(add_fit_button) # add widgets to layout test_layout.addWidget(self._fitter_select) test_layout.addLayout(button_layout) main_layout.addLayout(test_layout) main_layout.addWidget(self._data_out) self.setWindowTitle('AIC Test')
def layout(self): """ """ main_layout = QW.QVBoxLayout(self) form_layout = QW.QFormLayout() pytc_docs = "<a href=\"https://pytc.readthedocs.io/en/latest/\">documentation</a>" gui_docs = "<a href=\"https://pytc-gui.readthedocs.io/en/latest/\">documentation</a>" pytc_label = QW.QLabel(pytc_docs) pytc_label.setOpenExternalLinks(True) gui_label = QW.QLabel(gui_docs) gui_label.setOpenExternalLinks(True) form_layout.addRow(QW.QLabel("pytc:"), pytc_label) form_layout.addRow(QW.QLabel("pytc-gui:"), gui_label) OK_button = QW.QPushButton("OK", self) OK_button.clicked.connect(self.close) main_layout.addLayout(form_layout) main_layout.addWidget(OK_button) self.setWindowTitle("Documentation")
def layout(self): """ Populate the window. """ self._main_layout = QW.QVBoxLayout(self) self._form_layout = QW.QFormLayout() # Input box holding name self._global_var_input = QW.QLineEdit(self) self._global_var_input.setText("global") self._global_var_input.editingFinished.connect(self._check_name) # Final OK button self._OK_button = QW.QPushButton("OK", self) self._OK_button.clicked.connect(self._ok_button_handler) # Add to form self._form_layout.addRow(QW.QLabel("New Global Variable:"), self._global_var_input) # add to main layout self._main_layout.addLayout(self._form_layout) self._main_layout.addWidget(self._OK_button) self.setWindowTitle("Add new global variable")
def __init__(self): super(TracebackWindow, self).__init__() self.framelist = [] self.ret_add = 0x0 self.setWindowTitle("Traceback") self.setLayout(QtWidgets.QVBoxLayout()) self._layout = self.layout() # Creates the rich text viewer that displays the traceback self._textBrowser = QtWidgets.QTextBrowser() self._textBrowser.setOpenLinks(False) self._textBrowser.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont)) self._layout.addWidget(self._textBrowser) # Creates the button that displays the return address self._ret = QtWidgets.QPushButton() self._ret.setFlat(True) self._layout.addWidget(self._ret) self.resize(self.width(), int(self.height() * 0.5)) self.setObjectName('Traceback_Window')
def __init__(self, parent): super(CFsTab, self).__init__(parent) self.panel = parent # Not visible when instantiated self.cf_table = CFTable() self.no_method_label = QtWidgets.QLabel(self.NO_METHOD) container = QtWidgets.QVBoxLayout() container.addWidget(header('Characterization Factors:')) container.addWidget(horizontal_line()) container.addWidget(self.no_method_label) container.addWidget(self.cf_table) container.setAlignment(QtCore.Qt.AlignTop) signals.project_selected.connect(self.hide_cfs_table) signals.method_selected.connect(self.add_cfs_table) self.setLayout(container)
def __init__(self, parent=None): super().__init__(parent) self.path_edit = QtWidgets.QLineEdit() self.registerField('dirpath*', self.path_edit) self.browse_button = QtWidgets.QPushButton('Browse') self.browse_button.clicked.connect(self.get_directory) layout = QtWidgets.QVBoxLayout() layout.addWidget(QtWidgets.QLabel( 'Choose location of existing ecospold2 directory:')) layout.addWidget(self.path_edit) browse_lay = QtWidgets.QHBoxLayout() browse_lay.addWidget(self.browse_button) browse_lay.addStretch(1) layout.addLayout(browse_lay) self.setLayout(layout)
def __init__(self, parent=None): super().__init__(parent) self.wizard = self.parent() self.complete = False self.description_label = QtWidgets.QLabel('Login to the ecoinvent homepage:') self.username_edit = QtWidgets.QLineEdit() self.username_edit.setPlaceholderText('ecoinvent username') self.password_edit = QtWidgets.QLineEdit() self.password_edit.setPlaceholderText('ecoinvent password'), self.password_edit.setEchoMode(QtWidgets.QLineEdit.Password) self.login_button = QtWidgets.QPushButton('login') self.login_button.clicked.connect(self.login) self.login_button.setCheckable(True) self.password_edit.returnPressed.connect(self.login_button.click) self.success_label = QtWidgets.QLabel('') layout = QtWidgets.QVBoxLayout() layout.addWidget(self.description_label) layout.addWidget(self.username_edit) layout.addWidget(self.password_edit) hlay = QtWidgets.QHBoxLayout() hlay.addWidget(self.login_button) hlay.addStretch(1) layout.addLayout(hlay) layout.addWidget(self.success_label) self.setLayout(layout)
def setGraphView(self, graphView): self.graphView = graphView # Setup Layout layout = QtWidgets.QVBoxLayout(self) layout.addWidget(self.graphView) self.setLayout(layout) # Setup hotkeys for the following actions. deleteShortcut = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Delete), self) deleteShortcut.activated.connect(self.graphView.deleteSelectedNodes) frameShortcut = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_F), self) frameShortcut.activated.connect(self.graphView.frameSelectedNodes) frameShortcut = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_A), self) frameShortcut.activated.connect(self.graphView.frameAllNodes)
def __init__(self, parent, f=Qt.WindowCloseButtonHint): super(DirectDownload, self).__init__(parent, f) self.parent = parent self.setWindowTitle('Download Progress') self.setWindowModality(Qt.ApplicationModal) self.setMinimumWidth(485) self.setContentsMargins(20, 20, 20, 20) layout = QVBoxLayout() self.progress_label = QLabel(alignment=Qt.AlignCenter) self.progress = QProgressBar(self.parent) self.progress.setMinimum(0) self.progress.setMaximum(100) layout.addWidget(self.progress_label) layout.addWidget(self.progress) self.setLayout(layout)
def __init__( self, app, parent, rel_path, abs_path, info ): super().__init__( parent ) self.app = app self.setWindowTitle( T_('Svn Info for %s') % (rel_path,) ) self.v_layout = QtWidgets.QVBoxLayout() self.group = None self.grid = None self.addGroup( T_('Entry') ) self.addRow( T_('Path:'), abs_path ) self.initFromInfo( info ) self.buttons = QtWidgets.QDialogButtonBox() self.buttons.addButton( self.buttons.Close ) self.buttons.rejected.connect( self.close ) self.v_layout.addWidget( self.buttons ) self.setLayout( self.v_layout )
def __init__( self, parent=None, size=None ): super().__init__( parent ) self.tabs = QtWidgets.QTabWidget() self.buttons = QtWidgets.QDialogButtonBox() self.ok_button = self.buttons.addButton( self.buttons.Ok ) self.buttons.addButton( self.buttons.Cancel ) self.buttons.accepted.connect( self.accept ) self.buttons.rejected.connect( self.reject ) # must add the tabs at this stage or that will not display self.completeTabsInit() self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget( self.tabs ) self.layout.addWidget( self.buttons ) self.setLayout( self.layout ) if size is not None: em = self.app.fontMetrics().width( 'm' ) ex = self.app.fontMetrics().lineSpacing() self.resize( size[0]*em, size[1]*ex )
def setupUi(self, Help): Help.setObjectName("Help") Help.resize(456, 582) self.gridLayout = QtWidgets.QGridLayout(Help) self.gridLayout.setObjectName("gridLayout") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.textBrowser = QtWidgets.QTextBrowser(Help) self.textBrowser.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.textBrowser.setOpenExternalLinks(True) self.textBrowser.setObjectName("textBrowser") self.verticalLayout.addWidget(self.textBrowser) self.buttonBox = QtWidgets.QDialogButtonBox(Help) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) self.retranslateUi(Help) QtCore.QMetaObject.connectSlotsByName(Help)
def __init__(self, parent, channels, selected=[], title="Pick channels"): super().__init__(parent) self.setWindowTitle(title) self.initial_selection = selected vbox = QVBoxLayout(self) self.channels = QListWidget() self.channels.insertItems(0, channels) self.channels.setSelectionMode(QListWidget.ExtendedSelection) for i in range(self.channels.count()): if self.channels.item(i).data(0) in selected: self.channels.item(i).setSelected(True) vbox.addWidget(self.channels) self.buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) vbox.addWidget(self.buttonbox) self.buttonbox.accepted.connect(self.accept) self.buttonbox.rejected.connect(self.reject) self.channels.itemSelectionChanged.connect(self.toggle_buttons) self.toggle_buttons() # initialize OK button state
def __init__(self, parent=None): QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowCloseButtonHint) self.setWindowTitle("Highlighter v%s" % __version__) highlighter_layout = QtWidgets.QVBoxLayout() button_highlight = QtWidgets.QPushButton("&Highlight instructions") button_highlight.setDefault(True) button_highlight.clicked.connect(self.highlight) highlighter_layout.addWidget(button_highlight) button_clear = QtWidgets.QPushButton("&Clear all highlights") button_clear.clicked.connect(self.clear_colors) highlighter_layout.addWidget(button_clear) button_cancel = QtWidgets.QPushButton("&Close") button_cancel.clicked.connect(self.close) highlighter_layout.addWidget(button_cancel) self.setMinimumWidth(180) self.setLayout(highlighter_layout)
def __init__(self, configurations=None, parent=None): super(SessionInfoWidget, self).__init__(parent=parent) main_layout = QtWidgets.QVBoxLayout() self.setLayout(main_layout) form_layout = QtWidgets.QFormLayout() form_layout.setFormAlignment(QtCore.Qt.AlignVCenter) main_layout.addLayout(form_layout) if configurations is not None: self._config_combo_box = QtWidgets.QComboBox() form_layout.addRow("Configuration", self._config_combo_box) for config in configurations: self._config_combo_box.addItem(config) self._subject_line_edit = QtWidgets.QLineEdit() form_layout.addRow("Subject", self._subject_line_edit) self._button = QtWidgets.QPushButton("Start") main_layout.addWidget(self._button) self._button.clicked.connect(self._on_button_click)
def __init__(self): QtWidgets.QColorDialog.__init__(self) self.setOption(QtWidgets.QColorDialog.NoButtons) """ QColorDialog [0] PyQt5.QtWidgets.QVBoxLayout [1] PyQt5.QtWidgets.QWidget | Basic Color Grid [2] PyQt5.QtWidgets.QLabel | Basic Color Label [3] PyQt5.QtWidgets.QPushButton | Pick Screen Color Button [4] PyQt5.QtWidgets.QLabel | Background for the colour preview [5] PyQt5.QtWidgets.QWidget | Custom Color Grid [6] PyQt5.QtWidgets.QLabel | Custom Color Label [7] PyQt5.QtWidgets.QPushButton | Add to Custom Colors Button [8] PyQt5.QtWidgets.QFrame | Hue Saturation Picker [9] PyQt5.QtWidgets.QWidget | Intensity Slider [10] PyQt5.QtWidgets.QWidget | Value and Preview [11] PyQt5.QtWidgets.QDialogButtonBox | Dialog Buttons [12] PyQt5.QtCore.QTimer | ??? """ self.children()[10].children()[16].setText("&Hex:") [self.children()[1].setParent(None) for elem in range(7)] # Remove elements 1-7 self.updateColor() # Elements 0, 8, 9, 10, 11 are important
def setupUi(self, AvailableModules): AvailableModules.setObjectName("AvailableModules") AvailableModules.resize(640, 480) self.verticalLayout = QtWidgets.QVBoxLayout(AvailableModules) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.table_modules = QtWidgets.QTableWidget(AvailableModules) self.table_modules.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection) self.table_modules.setCornerButtonEnabled(True) self.table_modules.setRowCount(0) self.table_modules.setColumnCount(3) self.table_modules.setObjectName("table_modules") self.table_modules.horizontalHeader().setSortIndicatorShown(False) self.table_modules.horizontalHeader().setStretchLastSection(True) self.table_modules.verticalHeader().setVisible(False) self.verticalLayout.addWidget(self.table_modules) self.retranslateUi(AvailableModules) QtCore.QMetaObject.connectSlotsByName(AvailableModules)
def __init__(self, *args, **kwargs): super(FileWatch, self).__init__(*args, **kwargs) self.filePath = "" self.lastEdited = 0 self.fileContent = "" self.propertiesWidget = QWidget() self.vlayout = QVBoxLayout() self.lineEdit = QLineEdit() self.lineEdit.textChanged.connect(self.lineEditTextChanges) self.vlayout.addWidget(self.lineEdit) self.vlayout.addItem(QSpacerItem(40, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.propertiesWidget.setLayout(self.vlayout) self.timer = QTimer() self.timer.timeout.connect(self.checkFileChange) self.timer.start(200)
def __init__(self, *args, **kwargs): super(FullScreenQuad, self).__init__(*args, **kwargs) self.propertiesWidget = QWidget() self.vlayout = QVBoxLayout() self.xoffsetWidget = QDoubleSpinBox() self.xoffsetWidget.setMaximum(9999) self.xoffsetWidget.setMinimum(-9999) self.yoffsetWidget = QDoubleSpinBox() self.yoffsetWidget.setMaximum(9999) self.yoffsetWidget.setMinimum(-9999) self.vlayout.addWidget(self.xoffsetWidget) self.vlayout.addWidget(self.yoffsetWidget) self.xoffsetWidget.valueChanged.connect(self.offsetchange) self.yoffsetWidget.valueChanged.connect(self.offsetchange) self.vlayout.addItem(QSpacerItem(40, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.propertiesWidget.setLayout(self.vlayout)
def __init__(self, *args, **kwargs): self.ownsheet = None self.sheets = None self.selectedSheet = None self.listSheetItems = {} super(SubSheet, self).__init__(*args, **kwargs) self.propertiesWidget = QWidget() self.vlayout = QVBoxLayout() self.listWidget = QListWidget() self.listWidget.itemClicked.connect(self.listClicked) self.vlayout.addWidget(self.listWidget) self.vlayout.addItem(QSpacerItem(40, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.propertiesWidget.setLayout(self.vlayout)
def __init__(self): QWidget.__init__(self) self.resize(1600, 940) self.setWindowTitle('OpenVR tracking data') self.webview = QWebEngineView() self.button = QPushButton('Quit', self) self.button.clicked.connect(self.close) layout = QVBoxLayout(self) layout.setSpacing(0) # layout.setMargin(0) layout.addWidget(self.button) layout.addWidget(self.webview) # XXX check result openvr.init(openvr.VRApplication_Scene) poses_t = openvr.TrackedDevicePose_t * openvr.k_unMaxTrackedDeviceCount self.poses = poses_t() self.timer = QTimer() self.timer.timeout.connect(self.update_page) self.timer.start(50) # ms
def __init__(self, parent=None): super(Adventure, self).__init__(parent) # # Top-half of the # self.image_panel = QtWidgets.QLabel() self.image_panel.setAlignment(QtCore.Qt.AlignCenter) self.image = QtGui.QPixmap("image.jpg") self.image_panel.setPixmap(self.image) self.text_panel = QtWidgets.QTextEdit() self.text_panel.setReadOnly(True) self.text_panel.setTextBackgroundColor(QtGui.QColor("blue")) self.text_panel.setHtml("""<h1>Hello, World!</h1> <p>You are in a spacious ballroom with the sound of music playing all around you.</p> """) self.data_panel = QtWidgets.QTextEdit() self.data_panel.setReadOnly(True) self.input = QtWidgets.QLineEdit() layout = QtWidgets.QVBoxLayout() layout.addWidget(self.image_panel, 1) hlayout = QtWidgets.QHBoxLayout() hlayout.addWidget(self.text_panel, 3) hlayout.addWidget(self.data_panel, 1) layout.addLayout(hlayout, 1) layout.addWidget(self.input) self.setLayout(layout) self.setWindowTitle("Westpark Adventure")
def __init__(self, parent): super(QWidget, self).__init__(parent) self.layout = QVBoxLayout(self) # Initialize tab screen self.tabs = QTabWidget() self.tab1 = QWidget() self.tab2 = QWidget() self.tabs.resize(300,200) # Add tabs self.tabs.addTab(self.tab1,"Tab 1") self.tabs.addTab(self.tab2,"Tab 2") # Create first tab self.tab1.layout = QVBoxLayout(self) self.pushButton1 = QPushButton("PyQt5 button") self.tab1.layout.addWidget(self.pushButton1) self.tab1.setLayout(self.tab1.layout) # Add tabs to widget self.layout.addWidget(self.tabs) self.setLayout(self.layout)
def window(): app = QtWidgets.QApplication(sys.argv) w = QtWidgets.QWidget() b = QtWidgets.QPushButton('Push Me') l = QtWidgets.QLabel('Look at me') h_box = QtWidgets.QHBoxLayout() h_box.addStretch() h_box.addWidget(l) h_box.addStretch() v_box = QtWidgets.QVBoxLayout() v_box.addWidget(b) v_box.addLayout(h_box) w.setLayout(v_box) w.setWindowTitle('PyQt5 Lesson 4') w.show() sys.exit(app.exec_())
def init_ui(self): self.le = QtWidgets.QLineEdit() self.b1 = QtWidgets.QPushButton('Clear') self.b2 = QtWidgets.QPushButton('Print') v_box = QtWidgets.QVBoxLayout() v_box.addWidget(self.le) v_box.addWidget(self.b1) v_box.addWidget(self.b2) self.setLayout(v_box) self.setWindowTitle('PyQt5 Lesson 7') self.b1.clicked.connect(self.btn_clk) self.b2.clicked.connect(self.btn_clk) self.show()
def init_ui(self): self.b = QtWidgets.QPushButton('Push Me') self.l = QtWidgets.QLabel('I have not been clicked yet') h_box = QtWidgets.QHBoxLayout() h_box.addStretch() h_box.addWidget(self.l) h_box.addStretch() v_box = QtWidgets.QVBoxLayout() v_box.addWidget(self.b) v_box.addLayout(h_box) self.setLayout(v_box) self.setWindowTitle('PyQt5 Lesson 5') self.b.clicked.connect(self.btn_click) self.show()
def init_ui(self): v_layout = QVBoxLayout() h_layout = QHBoxLayout() h_layout.addWidget(self.clr_btn) h_layout.addWidget(self.sav_btn) h_layout.addWidget(self.opn_btn) v_layout.addWidget(self.text) v_layout.addLayout(h_layout) self.sav_btn.clicked.connect(self.save_text) self.clr_btn.clicked.connect(self.clear_text) self.opn_btn.clicked.connect(self.open_text) self.setLayout(v_layout) self.setWindowTitle('PyQt5 TextEdit') self.show()
def init_ui(self): v_layout = QVBoxLayout() h_layout = QHBoxLayout() h_layout.addWidget(self.clr_btn) h_layout.addWidget(self.sav_btn) h_layout.addWidget(self.opn_btn) v_layout.addWidget(self.text) v_layout.addLayout(h_layout) self.sav_btn.clicked.connect(self.save_text) self.clr_btn.clicked.connect(self.clear_text) self.opn_btn.clicked.connect(self.open_text) self.setLayout(v_layout) #self.setWindowTitle("notepad") #self.setWindowIcon(QIcon('notepad.png')) self.show()
def __init__(self, parent=None): super(ConsoleWidget, self).__init__(parent) self.parent = parent self.edit = VideoConsole(self) buttons = QDialogButtonBox() buttons.setCenterButtons(True) clearButton = buttons.addButton('Clear', QDialogButtonBox.ResetRole) clearButton.clicked.connect(self.edit.clear) closeButton = buttons.addButton(QDialogButtonBox.Close) closeButton.clicked.connect(self.close) closeButton.setDefault(True) layout = QVBoxLayout() layout.addWidget(self.edit) layout.addWidget(buttons) self.setLayout(layout) self.setWindowTitle('{0} Console'.format(qApp.applicationName())) self.setWindowFlags(Qt.Window | Qt.WindowCloseButtonHint) self.setWindowModality(Qt.NonModal)
def __init__(self, icon: str, parent=None, f=Qt.Dialog | Qt.FramelessWindowHint): super(Notification, self).__init__(parent, f) self.parent = parent self.theme = self.parent.theme self.setObjectName('notification') self.setContentsMargins(10, 10, 10, 10) self.shown.connect(lambda: QTimer.singleShot(self.duration * 1000, self.fadeOut)) self.setWindowModality(Qt.ApplicationModal) self.setMinimumWidth(550) self._title, self._message = '', '' self.buttons = [] self.msgLabel = QLabel(self._message, self) self.msgLabel.setWordWrap(True) logo_label = QLabel('<img src="{}" width="82" />'.format(icon), self) logo_label.setFixedSize(82, 82) self.left_layout = QVBoxLayout() self.left_layout.addWidget(logo_label) layout = QHBoxLayout() layout.addStretch(1) layout.addLayout(self.left_layout) layout.addSpacing(10) layout.addWidget(self.msgLabel, Qt.AlignVCenter) layout.addStretch(1) self.setLayout(layout)
def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent) # Layout self.runmenulayout = QtWidgets.QVBoxLayout() # Widget self.runmenuLabel = QtWidgets.QLabel() self.runmenuLabel.setText("Task is running\nPlease wait...") # self.runmenuMovieLabel = QtWidgets.QLabel() # self.runmenuMovie = QtGui.QMovie(":/resources/runmenu.gif") # self.runmenuMovieLabel.setMovie(self.runmenuMovie) # self.runmenuMovieLabel.show() # Add Widget self.runmenulayout.addWidget(self.runmenuLabel) # self.runmenulayout.addWidget(self.runmenuMovieLabel) # Set layout self.runmenulayout.setAlignment(QtCore.Qt.AlignCenter) self.runmenulayout.setSpacing(0) self.runmenulayout.setContentsMargins(10, 0, 10, 0) self.setLayout(self.runmenulayout) # Stylesheet self.setStyleSheet("QLabel{background:transparent; color:#3d5159; font-family:'Segoe UI'; font-size:13pt; border:none;}")
def __init__(self, parent=None): QtWidgets.QFrame.__init__(self, parent=parent) self.logger = QtWidgets.QPlainTextEdit(parent=self) self.logger.setReadOnly(True) self.logger.setLineWrapMode(QtWidgets.QPlainTextEdit.NoWrap) self.logger.setMinimumWidth(1100) self.buffer = '' self.clear_button = QtWidgets.QPushButton('Clear Log', parent=self) self.clear_button.clicked.connect(self.clear_log) self.save_button = QtWidgets.QPushButton('Save Log As...', parent=self) self.save_button.clicked.connect(self.save_log) self.lay = QtWidgets.QVBoxLayout(self) self.lay.addWidget(self.logger) self.lay.addWidget(self.clear_button) self.lay.addWidget(self.save_button)
def __init__(self, text, size_min = None, size_max = None, parent = None): """ Initialization of the CfgLineEdit class (text edit, one line). @param text: text string associated with the line edit @param size_min: min length (int) @param size_max: max length (int) """ QWidget.__init__(self, parent) self.lineedit = QLineEdit(parent) self.setSpec({'minimum': size_min, 'maximum': size_max, 'comment': ''}) if size_min is not None: self.size_min = size_min else: self.size_min = 0 self.label = QLabel(text, parent) self.layout = QVBoxLayout(parent) self.layout.addWidget(self.label) self.layout.addWidget(self.lineedit) self.setLayout(self.layout) self.layout.setSpacing(1) #Don't use too much space, it makes the option window too big otherwise
def setupUi(self, chatBox,message): chatBox.setObjectName("chatBox") chatBox.resize(473, 294) self.gridLayout = QtWidgets.QGridLayout(chatBox) self.gridLayout.setObjectName("gridLayout") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.chatLabel = QtWidgets.QLabel(chatBox) self.chatLabel.setObjectName("chatLabel") self.verticalLayout.addWidget(self.chatLabel) self.userChat = chatText(chatBox) self.userChat.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.userChat.setObjectName("userChat") self.verticalLayout.addWidget(self.userChat) self.gridLayout.addLayout(self.verticalLayout, 1, 0, 4, 1) self.chat = QtWidgets.QTextEdit(chatBox) self.chat.setEnabled(True) self.chat.setReadOnly(True) self.chat.setObjectName("chat") self.gridLayout.addWidget(self.chat, 0, 0, 1, 2) self.listOnline = QtWidgets.QPushButton(chatBox) self.listOnline.setObjectName("listOnline") self.gridLayout.addWidget(self.listOnline, 1, 1, 1, 1) self.sendButton = QtWidgets.QPushButton(chatBox) self.sendButton.setObjectName("sendButton") self.gridLayout.addWidget(self.sendButton, 3, 1, 1, 1) self.exitButton = QtWidgets.QPushButton(chatBox) self.exitButton.setObjectName("exitButton") self.gridLayout.addWidget(self.exitButton, 4, 1, 1, 1) self.fileSendButton = QtWidgets.QPushButton(chatBox) self.fileSendButton.setObjectName("fileSendButton") self.gridLayout.addWidget(self.fileSendButton, 2, 1, 1, 1) self.retranslateUi(chatBox,message) QtCore.QMetaObject.connectSlotsByName(chatBox)
def setupUi(self, chatBox,message): chatBox.setObjectName("chatBox") chatBox.resize(473, 294) self.gridLayout = QtWidgets.QGridLayout(chatBox) self.gridLayout.setObjectName("gridLayout") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.chatLabel = QtWidgets.QLabel(chatBox) self.chatLabel.setObjectName("chatLabel") self.verticalLayout.addWidget(self.chatLabel) self.userChat = QtWidgets.QTextEdit(chatBox) self.userChat.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.userChat.setObjectName("userChat") self.verticalLayout.addWidget(self.userChat) self.gridLayout.addLayout(self.verticalLayout, 1, 0, 4, 1) self.chat = QtWidgets.QTextEdit(chatBox) self.chat.setEnabled(True) self.chat.setReadOnly(True) self.chat.setObjectName("chat") self.gridLayout.addWidget(self.chat, 0, 0, 1, 2) self.listOnline = QtWidgets.QPushButton(chatBox) self.listOnline.setObjectName("listOnline") self.gridLayout.addWidget(self.listOnline, 1, 1, 1, 1) self.sendButton = QtWidgets.QPushButton(chatBox) self.sendButton.setObjectName("sendButton") self.gridLayout.addWidget(self.sendButton, 3, 1, 1, 1) self.exitButton = QtWidgets.QPushButton(chatBox) self.exitButton.setObjectName("exitButton") self.gridLayout.addWidget(self.exitButton, 4, 1, 1, 1) self.fileSendButton = QtWidgets.QPushButton(chatBox) self.fileSendButton.setObjectName("fileSendButton") self.gridLayout.addWidget(self.fileSendButton, 2, 1, 1, 1) self.retranslateUi(chatBox,message) self.exitButton.clicked.connect(chatBox.close) self.sendButton.clicked.connect(self.userChat.clear) self.fileSendButton.clicked.connect(self.userChat.clear) QtCore.QMetaObject.connectSlotsByName(chatBox)
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(188, 48) Dialog.setWindowTitle("") self.horizontalLayout = QtWidgets.QHBoxLayout(Dialog) self.horizontalLayout.setObjectName("horizontalLayout") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setCenterButtons(True) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.horizontalLayout.addLayout(self.verticalLayout) self.retranslateUi(Dialog) self.buttonBox.accepted.connect(Dialog.accept) self.buttonBox.rejected.connect(Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)