我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtWidgets.QLabel()。
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, ebeveyn=None): super(Son, self).__init__(ebeveyn) self.e = ebeveyn self.kapanacak_mi =False kutu = QGridLayout() self.setLayout(kutu) milis_logo = QLabel() milis_logo.setAlignment(Qt.AlignCenter) milis_logo.setPixmap(QPixmap("./resimler/milis-logo.svg")) kutu.addWidget(milis_logo,0,0,1,2) self.veda_label = QLabel() self.veda_label.setAlignment(Qt.AlignCenter) self.veda_label.setWordWrap(True) kutu.addWidget(self.veda_label,1,0,1,2) self.denemeye_devam = QRadioButton() self.denemeye_devam.setIcon(QIcon("./resimler/cik.svg")) self.denemeye_devam.setIconSize(QSize(50,50)) self.denemeye_devam.toggled.connect(self.degisti) kutu.addWidget(self.denemeye_devam,2,0,1,1) self.kapat = QRadioButton() self.kapat.setIcon(QIcon("./resimler/yeniden-baslat.svg")) self.kapat.setIconSize(QSize(50,50)) self.kapat.toggled.connect(self.degisti) kutu.addWidget(self.kapat,2,1,1,1) self.denemeye_devam.setChecked(True)
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 setupUi(self, Form): Form.setObjectName("Form") Form.resize(582, 558) self.gridLayout = QtWidgets.QGridLayout(Form) self.gridLayout.setObjectName("gridLayout") self.label_FilePath = QtWidgets.QLabel(Form) self.label_FilePath.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByMouse) self.label_FilePath.setObjectName("label_FilePath") self.gridLayout.addWidget(self.label_FilePath, 0, 0, 1, 1) self.textBrowser_LogContent = QtWidgets.QTextBrowser(Form) self.textBrowser_LogContent.setLineWrapMode(QtWidgets.QTextEdit.NoWrap) self.textBrowser_LogContent.setObjectName("textBrowser_LogContent") self.gridLayout.addWidget(self.textBrowser_LogContent, 1, 0, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
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 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): """ Create layout. """ self._main_layout = QW.QHBoxLayout(self) self._label = QW.QLabel(self._meta_name) self._meta = QW.QLineEdit() self._meta.textChanged.connect(self._meta_handler) self._meta.editingFinished.connect(self._meta_handler) self._main_layout.addWidget(self._label) self._main_layout.addWidget(self._meta) # Load in parameters from FitParameter object self.update()
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, text="Loading..."): super(MessageBox, self).__init__() self.setWindowTitle("Messages") self.setLayout(QtWidgets.QHBoxLayout()) self._layout = self.layout() self._gif = QtWidgets.QLabel() movie = QtGui.QMovie("loading.gif") self._gif.setMovie(movie) movie.start() self._layout.addWidget(self._gif) self._message = QtWidgets.QLabel() self._message.setText(text) self._layout.addWidget(self._message) self.setObjectName('Message_Window')
def __init__(self, parent): super(DatabaseWidget, self).__init__(parent) # Labels self.label_no_database_selected = QtWidgets.QLabel("Select a database (double-click on table).") # Buttons self.add_default_data_button = QtWidgets.QPushButton( 'Add Default Data (Biosphere flows, LCIA methods)') self.new_database_button = QtWidgets.QPushButton('New Database') self.import_database_button = QtWidgets.QPushButton('Import Database') # Header widget self.header_layout.addWidget(self.add_default_data_button) self.header_layout.addWidget(self.new_database_button) self.header_layout.addWidget(self.import_database_button) # Overall Layout self.v_layout.addWidget(self.label_no_database_selected) self.connect_signals()
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.wizard = self.parent() self.path_edit = QtWidgets.QLineEdit() self.registerField('archivepath*', self.path_edit) self.browse_button = QtWidgets.QPushButton('Browse') self.browse_button.clicked.connect(self.get_archive) layout = QtWidgets.QVBoxLayout() layout.addWidget(QtWidgets.QLabel( 'Choose location of 7z archive:')) 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 __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 setupUi(self, About): About.setObjectName("About") About.resize(401, 117) About.setMinimumSize(QtCore.QSize(401, 117)) About.setMaximumSize(QtCore.QSize(401, 117)) self.buttonBox = QtWidgets.QDialogButtonBox(About) self.buttonBox.setGeometry(QtCore.QRect(10, 80, 381, 32)) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setCenterButtons(True) self.buttonBox.setObjectName("buttonBox") self.label = QtWidgets.QLabel(About) self.label.setGeometry(QtCore.QRect(0, 20, 401, 21)) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(About) self.label_2.setGeometry(QtCore.QRect(0, 40, 401, 20)) self.label_2.setAlignment(QtCore.Qt.AlignCenter) self.label_2.setObjectName("label_2") self.retranslateUi(About) self.buttonBox.clicked['QAbstractButton*'].connect(About.close) QtCore.QMetaObject.connectSlotsByName(About)
def __init__( self, app, parent ): self.app = app super().__init__( parent ) self.setWindowTitle( T_('Git Credentials - %s') % (' '.join( app.app_name_parts ),) ) self.url = QtWidgets.QLabel() self.username = QtWidgets.QLineEdit() self.password = QtWidgets.QLineEdit() self.password.setEchoMode( self.password.Password ) self.username.textChanged.connect( self.nameTextChanged ) self.password.textChanged.connect( self.nameTextChanged ) em = self.fontMetrics().width( 'M' ) self.addRow( T_('URL'), self.url ) self.addRow( T_('Username'), self.username, min_width=50*em ) self.addRow( T_('Password'), self.password ) self.addButtons()
def addRow( self, label, value ): value = str(value) label_ctrl = QtWidgets.QLabel( label ) label_ctrl.setAlignment( QtCore.Qt.AlignRight ) if '\n' in value: value_ctrl = QtWidgets.QPlainTextEdit() else: value_ctrl = QtWidgets.QLineEdit() value_ctrl.setMinimumWidth( 600 ) value_ctrl.setReadOnly( True ) value_ctrl.setText( value ) row = self.grid.rowCount() self.grid.addWidget( label_ctrl, row, 0 ) self.grid.addWidget( value_ctrl, row, 1 )
def __init__( self, parent, trust_info ): super().__init__( parent ) self.setWindowTitle( T_('SVN SSL Server Trust') ) self.realm = QtWidgets.QLabel( trust_info['realm'] ) self.save_trust = QtWidgets.QCheckBox() self.save_trust.setCheckState( QtCore.Qt.Unchecked ) em = self.fontMetrics().width( 'M' ) self.addRow( T_('Hostname'), trust_info['hostname'], min_width=50*em ) self.addRow( T_('Finger Print'), trust_info['finger_print'] ) self.addRow( T_('Valid From'), trust_info['valid_from'] ) self.addRow( T_('Valid Until'), trust_info['valid_until'] ) self.addRow( T_('Issuer Dname'), trust_info['issuer_dname'] ) self.addRow( T_('Realm'), trust_info['realm'] ) self.addRow( T_('Save Trust'), self.save_trust ) self.addButtons()
def setupStatusBar( self, s ): self.status_general = QtWidgets.QLabel() self.status_progress = QtWidgets.QLabel() self.status_action = QtWidgets.QLabel() self.status_progress.setFrameStyle( QtWidgets.QFrame.Panel|QtWidgets.QFrame.Sunken ) self.status_action.setFrameStyle( QtWidgets.QFrame.Panel|QtWidgets.QFrame.Sunken ) s.addWidget( self.status_general, 1 ) s.addWidget( self.status_progress, 1 ) s.addWidget( self.status_action, 1 ) self.setStatusGeneral() self.setStatusAction() self.progress = wb_scm_progress.WbScmProgress( self.status_progress )
def setupStatusBar( self, s ): self.status_message = QtWidgets.QLabel() s.addWidget( self.status_message ) prefs = self.app.prefs.diff_window key = QtWidgets.QLabel() key.setTextFormat( QtCore.Qt.RichText ) key.setText( '<font color="%(normal)s">Key: </font>' '<font color="%(insert)s">Inserted text </font>' '<font color="%(delete)s">Deleted text </font>' '<font color="%(change)s">Changed text </font>' % {'normal': prefs.colour_normal.fg ,'insert': prefs.colour_insert_line.fg ,'delete': prefs.colour_delete_line.fg ,'change': prefs.colour_change_line.fg} ) key.setFrameStyle( QtWidgets.QFrame.Panel|QtWidgets.QFrame.Sunken ) self.status_bar_key_field = key s.addPermanentWidget( self.status_bar_key_field ) #------------------------------------------------------------
def __init__(self, option, value): # Make sure the value is a boolean if isinstance(value, str): if value.lower() in ['yes', "true", "on"]: value = True elif value in ['no', "false", "off"]: value = False super().__init__(option) self.check_box = QW.QCheckBox() self.check_box.setChecked(value) self.answer = QW.QLabel() self.switch_answer() self.check_box.clicked.connect(self.switch_answer) self.layout.addWidget(self.check_box) self.layout.addWidget(self.answer)
def __init__(self, run_button, combobox): super(SequanaFactory, self).__init__("sequana", run_button) self._imported_config = None self._choice_button = combobox # Some widgets to be used: a file browser for paired files fastq_filter = "Fastq file (*.fastq *.fastq.gz *.fq *.fq.gz)" self._sequana_paired_tab = FileBrowser(paired=True, file_filter=fastq_filter) self._sequana_readtag_label2 = QW.QLabel("Read tag (e.g. _[12].fastq)") self._sequana_readtag_lineedit2 = QW.QLineEdit("_R[12]_") # Set the file browser input_directory tab self._sequana_directory_tab = FileBrowser(directory=True) self._sequana_readtag_label = QW.QLabel("Read tag (e.g. _[12].fastq)") self._sequana_readtag_lineedit = QW.QLineEdit("_R[12]_") self._sequana_pattern_label = QW.QLabel( "<div><i>Optional</i> pattern (e.g., Samples_1?/*fastq.gz)</div>") self._sequana_pattern_lineedit = QW.QLineEdit() # triggers/connectors self._sequana_directory_tab.clicked_connect(self._switch_off_run) self._choice_button.activated.connect(self._switch_off_run) self._sequana_paired_tab.clicked_connect(self._switch_off_run)
def _get_value(self): """Return a string""" if isinstance(self.widget, QW.QSpinBox): value = self.widget.text() elif isinstance(self.widget, QW.QLabel): value = self.widget.text() elif isinstance(self.widget, FileBrowser): if self.widget.path_is_setup() is False: value = "" else: value = self.widget.get_filenames() else: try: value = self.widget.text() except: print("unknown widget" + str(type(self.widget))) value = "" return value
def drawUI(self, song_name="blank", song_artist="blank"): self.art = QLabel(self) self.art.resize(50, 50) #self.art.setPixmap(QPixmap("".join([song_name,'.jpg'])).scaled(50, 50, Qt.KeepAspectRatio, Qt.SmoothTransformation)) self.song_label = QLabel(self) self.song_label.setText(song_name) self.song_label.setStyleSheet("border-image: rgba(0, 0, 0, 0); color: rgba(255, 255, 255); font-size: 12pt; font-weight: 600;") self.song_label.move(60, 10) self.song_label.resize(180, 15) self.artist_label = QLabel(self) self.artist_label.setText(song_artist) self.artist_label.setStyleSheet("border-image: rgba(0, 0, 0, 0); color: rgba(255, 255, 255); font-size: 12pt; font-weight: 200;") self.artist_label.move(60, 25) self.artist_label.resize(180, 15)
def init_ui(self): # Creating a label self.progressLabel = QLabel('Progress Bar:', self) # Creating a progress bar and setting the value limits self.progressBar = QProgressBar(self) self.progressBar.setMaximum(100) self.progressBar.setMinimum(0) # Creating a Horizontal Layout to add all the widgets self.hboxLayout = QHBoxLayout(self) # Adding the widgets self.hboxLayout.addWidget(self.progressLabel) self.hboxLayout.addWidget(self.progressBar) # Setting the hBoxLayout as the main layout self.setLayout(self.hboxLayout) self.setWindowTitle('Dialog with Progressbar') self.show()
def __init__(self, addons, parent): super().__init__() self.setGeometry(300, 300, 300, 300) self.setWindowTitle('Open Addon') self.setWindowIcon(QIcon(ICON_PATH)) label = QLabel('Choose the addon you want to open.') grid = QGridLayout() grid.setSpacing(4) grid.addWidget(label, 0, 0) self.addonList = addons.split('-') self.addonList.remove('') self.parent = parent for i,j in enumerate(self.addonList): l = QLabel(str(i)+' -> '+j) grid.addWidget(l, i+1, 0) self.setLayout(grid) self.show()
def __init__(self): app = get_qtapp() super(MainWindow, self).__init__() app.installEventFilter(self) self._central_widget = QtWidgets.QWidget(self) self._layout = QtWidgets.QStackedLayout(self._central_widget) self.setCentralWidget(self._central_widget) status_bar = QtWidgets.QStatusBar(self) self.setStatusBar(status_bar) self._statusbar_label = QtWidgets.QLabel("status") status_bar.addPermanentWidget(self._statusbar_label) self.show()
def paintEvent(self, event): """ Overrides the QLabel method. Shouldn't need to be called directly. """ super().paintEvent(event) if self._pixmap_src is None: return self._pixmap = self._pixmap_src.scaled( self.size(), QtCore.Qt.KeepAspectRatio) x = (self.width() - self._pixmap.width())/2 y = (self.height() - self._pixmap.height())/2 painter = QtGui.QPainter(self) painter.drawPixmap(x, y, self._pixmap)
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 initUI(self): self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) label = QLabel('Python', self) label.move(50,50) label2 = QLabel('PyQt5', self) label2.move(100,100) label3 = QLabel('Examples', self) label3.move(150,150) label4 = QLabel('pytonspot.com', self) label4.move(200,200) self.show()
def setupUi(self, Form): Form.setObjectName("Form") Form.setGeometry(50,50,500,360) self.calendarWidget = QtWidgets.QCalendarWidget(Form) self.calendarWidget.setGridVisible(True) self.calendarWidget.setGeometry(QtCore.QRect(50, 50, 400, 250)) self.calendarWidget.setObjectName("calendarWidget") self.label = QtWidgets.QLabel(Form) date = self.calendarWidget.selectedDate() self.label.setText(date.toString()) self.label.setGeometry(QtCore.QRect(190, 200, 350, 270)) self.label.setObjectName("label") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
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.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 setupUi(self, TabTextual): TabTextual.setObjectName("TabTextual") TabTextual.resize(400, 300) self.gridLayout = QtWidgets.QGridLayout(TabTextual) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setHorizontalSpacing(0) self.gridLayout.setVerticalSpacing(4) self.gridLayout.setObjectName("gridLayout") self.textConfigEdit = TextConfigEditor(TabTextual) self.textConfigEdit.setObjectName("textConfigEdit") self.gridLayout.addWidget(self.textConfigEdit, 0, 0, 1, 1) self.correctness_label = QtWidgets.QLabel(TabTextual) self.correctness_label.setAlignment(QtCore.Qt.AlignCenter) self.correctness_label.setWordWrap(True) self.correctness_label.setObjectName("correctness_label") self.gridLayout.addWidget(self.correctness_label, 1, 0, 1, 1) self.retranslateUi(TabTextual) QtCore.QMetaObject.connectSlotsByName(TabTextual)
def __init__(self, ebeveyn=None): super(Konum, self).__init__(ebeveyn) self.e = ebeveyn kutu = QGridLayout() kutu.setAlignment(Qt.AlignCenter) self.setLayout(kutu) self.bigli_label = QLabel() kutu.addWidget(self.bigli_label,0,0,1,2) self.harita = HaritaWidget(self) kutu.addWidget(self.harita,1,0,1,2) self.bolge_label = QLabel() kutu.addWidget(self.bolge_label,2,0,1,1) self.sehir_label = QLabel() kutu.addWidget(self.sehir_label,2,1,1,1) self.bolge_combo = QComboBox() self.bolge_combo.currentTextChanged.connect(self.sehir_combo_doldur) kutu.addWidget(self.bolge_combo,3,0,1,1) self.sehir_combo = QComboBox() self.sehir_combo.currentTextChanged.connect(self.sehir_combo_degisti) kutu.addWidget(self.sehir_combo,3,1,1,1) self.bolge_combo_doldur() self.bolge_combo.setCurrentText("Europe") self.sehir_combo.setCurrentText("Istanbul")
def __init__(self, parent, slider: VideoSlider): super(VideoSliderWidget, self).__init__(parent) self.parent = parent self.slider = slider self.loaderEffect = OpacityEffect() self.loaderEffect.setEnabled(False) self.setGraphicsEffect(self.loaderEffect) self.setContentsMargins(0, 0, 0, 0) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.layout().setStackingMode(QStackedLayout.StackAll) self.genlabel = QLabel(self.parent) self.genlabel.setContentsMargins(0, 0, 0, 14) self.genlabel.setPixmap(QPixmap(':/images/generating-thumbs.png')) self.genlabel.setAlignment(Qt.AlignCenter) self.genlabel.hide() sliderLayout = QGridLayout() sliderLayout.setContentsMargins(0, 0, 0, 0) sliderLayout.setSpacing(0) sliderLayout.addWidget(self.slider, 0, 0) sliderLayout.addWidget(self.genlabel, 0, 0) sliderWidget = QWidget(self.parent) sliderWidget.setLayout(sliderLayout) self.addWidget(sliderWidget)
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 setupUi(self, Login): Login.setObjectName("Login") Login.resize(300, 400) Login.setMinimumSize(QtCore.QSize(300, 400)) Login.setMaximumSize(QtCore.QSize(300, 400)) self.pushButton = QtWidgets.QPushButton(Login) self.pushButton.setGeometry(QtCore.QRect(100, 320, 99, 27)) self.pushButton.setObjectName("pushButton") self.label_2 = QtWidgets.QLabel(Login) self.label_2.setGeometry(QtCore.QRect(28, 190, 68, 17)) self.label_2.setObjectName("label_2") self.lineEdit_2 = QtWidgets.QLineEdit(Login) self.lineEdit_2.setGeometry(QtCore.QRect(120, 190, 151, 27)) self.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.Password) self.lineEdit_2.setObjectName("lineEdit_2") self.label = QtWidgets.QLabel(Login) self.label.setGeometry(QtCore.QRect(28, 120, 68, 17)) self.label.setObjectName("label") self.lineEdit = QtWidgets.QLineEdit(Login) self.lineEdit.setGeometry(QtCore.QRect(120, 120, 151, 27)) self.lineEdit.setObjectName("lineEdit") self.retranslateUi(Login) QtCore.QMetaObject.connectSlotsByName(Login)
def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle('Manual Add Server') self.form = QtWidgets.QFormLayout(self) self.secure = QtWidgets.QCheckBox() self.address = QtWidgets.QLineEdit() self.port = QtWidgets.QLineEdit('32400') self.token = QtWidgets.QLineEdit() self.form.addRow(QtWidgets.QLabel('HTTPS?'), self.secure) self.form.addRow(QtWidgets.QLabel('Address'), self.address) self.form.addRow(QtWidgets.QLabel('Port'), self.port) self.form.addRow(QtWidgets.QLabel('Access Token (optional)'), self.token) self.buttons = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) self.form.addRow(self.buttons) self.buttons.rejected.connect(self.reject) self.buttons.accepted.connect(self.accept)
def __init__(self, text, unit = None, minimum = None, maximum = None, parent = None): """ Initialization of the CfgSpinBox class (used for int values). @param text: text string associated with the SpinBox @param minimum: min value (int) @param minimum: max value (int) """ QWidget.__init__(self, parent) self.spinbox = QSpinBox(parent) if unit is not None: self.setUnit(unit) self.setSpec({'minimum': minimum, 'maximum': maximum, 'comment': ''}) self.label = QLabel(text, parent) self.layout = QHBoxLayout(parent); self.spinbox.setMinimumWidth(200) #Provide better alignment with other items self.layout.addWidget(self.label) self.layout.addStretch() self.layout.addWidget(self.spinbox) self.setLayout(self.layout)
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 __init__(self, text, items_list = None, default_item = None, parent = None): """ Initialization of the CfgComboBox class (drop-down menu). @param text: text string associated with the combobox @param items_list: string list containing all the available options @param default_item: string containing the default selected item """ QWidget.__init__(self, parent) self.combobox = QComboBox(parent) if isinstance(items_list, (list, tuple)): self.setSpec({'string_list': items_list, 'comment': ''}) if default_item is not None: self.setValue(default_item) self.label = QLabel(text, parent) self.layout = QHBoxLayout(parent); self.combobox.setMinimumWidth(200) #Provide better alignment with other items self.layout.addWidget(self.label) self.layout.addStretch() self.layout.addWidget(self.combobox) self.setLayout(self.layout)
def __init__(self): super().__init__() self.layout = QtWidgets.QGridLayout() self.setStyleSheet("QPushButton{margin:0.5em 0 0 0;padding:0.25em 1em}") self.username_label = QtWidgets.QLabel("Nom d'utilisateur:", self) self.password_label = QtWidgets.QLabel("Mot de passe:", self) self.username_input = QtWidgets.QLineEdit(self) self.password_input = QtWidgets.QLineEdit(self) self.password_input.setEchoMode(QtWidgets.QLineEdit.Password) self.cancel_button = QtWidgets.QPushButton("Annuler", self) self.validation_button = QtWidgets.QPushButton("Ajouter", self) self.layout.addWidget(self.username_label, 0, 0) self.layout.addWidget(self.username_input, 1, 0, 1, 0) self.layout.addWidget(self.password_label, 2, 0) self.layout.addWidget(self.password_input, 3, 0, 1, 0) self.layout.addWidget(self.validation_button, 4, 0) self.layout.addWidget(self.cancel_button, 4, 1) self.cancel_button.setAutoDefault(False) self.setLayout(self.layout) self.cancel_button.clicked.connect(self.reject) self.validation_button.clicked.connect(self.accept)
def __init__(self, id_, name, value): super().__init__() self.id_ = id_ self.name = name self.value = value self.win = None self.label = QtWidgets.QLabel(name) self.input = QtWidgets.QDoubleSpinBox() self.input.setSuffix("€") self.input.setMaximum(999.99) self.input.setLocale(QtCore.QLocale('English')) self.label.setBuddy(self.input) self._build() self.layout = QtWidgets.QHBoxLayout(self) self.layout.addWidget(self.label) self.layout.addWidget(self.input)
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)