我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtWidgets.QLineEdit()。
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=None): super(AddressBook, self).__init__(parent) nameLabel = QLabel("Name:") self.nameLine = QLineEdit() addressLabel = QLabel("Address:") self.addressText = QTextEdit() mainLayout = QGridLayout() mainLayout.addWidget(nameLabel, 0, 0) mainLayout.addWidget(self.nameLine, 0, 1) mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop) mainLayout.addWidget(self.addressText, 1, 1) self.setLayout(mainLayout) self.setWindowTitle("Simple Address Book")
def __init__(self, min_, max_, float_=False): super(QwordSpinBox, self).__init__() self._minimum = min_ self._maximum = max_ self.int_ = float if float_ else int rx = QRegExp('-?\d{0,20}(?:\.\d{0,20})?' if float_ else '-?\d{0,20}') validator = QRegExpValidator(rx, self) self._lineEdit = QLineEdit(self) self._lineEdit.setText(str(self.int_(0))) self._lineEdit.setValidator(validator) self._lineEdit.textEdited.connect(partial(self.setValue, change=False)) self.editingFinished.connect(lambda: self.setValue(self.value(), update=False) or True) self.setLineEdit(self._lineEdit)
def __init__(self, item, name, val, app): super().__init__(item, [name + ' ']) self.name = name self.app = app self.required = '{%s}' % name in self.app.base_url if not self.required: self.setCheckState(0, Qt.Checked) self.last_check_state = Qt.Checked self.widget = QLineEdit() self.widget.setFrame(False) self.widget.setStyleSheet('padding: 1px 0') self.widget.textEdited.connect(self.value_changed) self.app.fuzzer.getTree.setItemWidget(self, 1, self.widget) self.widget.setText(val) self.value = val self.widget.setMouseTracking(True) self.widget.enterEvent = self.edit
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): """ Create layout. """ self._main_layout = QW.QHBoxLayout(self) if self._input_type is bool: self._select_widget = QW.QCheckBox() self._select_widget.stateChanged.connect(self._bool_handler) self._select_widget.setChecked(self._initial_value) elif self._input_type is str: self._select_widget = QW.QLineEdit() self._select_widget.editingFinished.connect(self._str_handler) self._select_widget.setText(self._initial_value) elif self._input_type is int: self._select_widget = QW.QLineEdit() self._select_widget.editingFinished.connect(self._int_handler) self._select_widget.setText(str(self._initial_value)) else: self._select_widget = QW.QLineEdit() self._select_widget.editingFinished.connect(self._general_handler) self._select_widget.setText(str(self._initial_value)) self._main_layout.addWidget(self._select_widget)
def _str_handler(self): """ Handler for string values. Parses QLineEdit. """ current = self._select_widget.text() try: new_value = current.strip() if new_value == "": raise ValueError color = "#FFFFFF" self._current_value = new_value self._valid = True except ValueError: color = "#FFB6C1" self._valid = False self._select_widget.setStyleSheet("QLineEdit {{ background-color: {} }}".format(color))
def _int_handler(self): """ Handler for int values. Parses QLineEdit. """ current = self._select_widget.text() try: # Make sure this scans as a string if type(ast.literal_eval(current)) != int: raise ValueError new_value = int(current) color = "#FFFFFF" self._current_value = new_value self._valid = True except ValueError: color = "#FFB6C1" self._valid = False self._select_widget.setStyleSheet("QLineEdit {{ background-color: {} }}".format(color))
def __init__(self,parent,fit,experiment,fit_param,float_view_cutoff=100000.): """ Initialize the class. parent: parent widget fit: FitContainer object experiment: pytc.ITCExperiment instance fit_param: pytc.FitParameter instance to wrap float_view_cutoff: how to show floats in QLineEdit boxes """ super().__init__() self._parent = parent self._fit = fit self._experiment = experiment self._p = fit_param self._float_view_cutoff = float_view_cutoff self._is_connector_param = False self._is_connected = False self.layout()
def _lower_handler(self): """ Handle lower bound entries. Turn pink of the value is bad. """ success = True try: value = float(self._lower.text()) if value > self._p.guess: raise ValueError except ValueError: success = False if success: color = "#FFFFFF" else: color = "#FFB6C1" self._lower.setStyleSheet("QLineEdit {{ background-color: {} }}".format(color)) if success: self._p.bounds = [value,self._p.bounds[1]] self._current_lower = value self._fit.emit_changed()
def _upper_handler(self): """ Handle upper bound entries. Turn pink of the value is bad. """ success = True try: value = float(self._upper.text()) if value < self._p.guess: raise ValueError except ValueError: success = False if success: color = "#FFFFFF" else: color = "#FFB6C1" self._upper.setStyleSheet("QLineEdit {{ background-color: {} }}".format(color)) if success: self._p.bounds = [self._p.bounds[0],value] self._current_upper = value self._fit.emit_changed()
def _general_handler(self): """ Handler for other values (str, float, int most likely). Parses QLineEdit. """ current = self._select_widget.text() try: new_value = self._value_type(current) color = "#FFFFFF" self._fit.set_experiment_attr(self._experiment,self._settable_name, new_value,purge_fit=True) self._current_value = new_value except ValueError: color = "#FFB6C1" self._select_widget.setStyleSheet("QLineEdit {{ background-color: {} }}".format(color))
def _widget_checker(self): """ Make sure widgets are good, turning bad widgets pink. """ for k in self._arg_widgets.keys(): caster = self._arg_types[k] if caster == bool: continue try: value = caster(self._arg_widgets[k].text()) if type(value) is str and value.strip() == "": raise ValueError color = "#FFFFFF" except ValueError: color = "#FFB6C1" self._arg_widgets[k].setStyleSheet("QLineEdit {{ background-color: {} }}".format(color))
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 update(self): """ Update the widgets. """ value = getattr(self._experiment,self._meta_name) if value != self._current_value: try: if value < 1/self._float_view_cutoff or value > self._float_view_cutoff: value_str = "{:.8e}".format(value) else: value_str = "{:.8f}".format(value) self._meta.setText(value_str) except TypeError: self._meta.setText("") color = "#FFFFFF" self._meta.setStyleSheet("QLineEdit {{ background-color: {} }}".format(color))
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 choosePathButton(self): sender = self.sender() if sender.objectName() == "pushButton_mediainfo_path": lineEdit = self.findChild(QLineEdit, "lineEdit_mediainfo_path") exe_name = "mediainfo" elif sender.objectName() == "pushButton_mp3guessenc_path": lineEdit = self.findChild(QLineEdit, "lineEdit_mp3guessenc_path") exe_name = "mp3guessenc" elif sender.objectName() == "pushButton_sox_path": lineEdit = self.findChild(QLineEdit, "lineEdit_sox_path") exe_name = "sox" elif sender.objectName() == "pushButton_ffprobe_path": lineEdit = self.findChild(QLineEdit, "lineEdit_ffprobe_path") exe_name = "ffprobe" elif sender.objectName() == "pushButton_aucdtect_path": lineEdit = self.findChild(QLineEdit, "lineEdit_aucdtect_path") exe_name = "aucdtect" if lineEdit is not None: path = lineEdit.text() file = str(QFileDialog.getOpenFileName(parent=self, caption=self.tr("Browse to")+" {} ".format(exe_name)+self.tr("executable file"), directory=path)[0]) if not file == "": lineEdit.setText(file)
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.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, app, parent, url, realm ): super().__init__( parent ) self.setWindowTitle( T_('Mercurial Credentials - %s') % (' '.join( app.app_name_parts ),) ) 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'), url ) self.addRow( T_('Realm'), realm ) self.addRow( T_('Username'), self.username, min_width=50*em ) self.addRow( T_('Password'), self.password ) self.addButtons()
def __init__( self, app ): super().__init__( app, T_('Hg') ) self.prefs = self.app.prefs.hg #------------------------------------------------------------ self.hg_program = QtWidgets.QLineEdit() if self.prefs.program is not None: self.hg_program.setText( str(self.prefs.program) ) else: # show the default self.hg_program.setText( hglib.HGPATH ) self.browse_program = QtWidgets.QPushButton( T_('Browse...') ) self.browse_program.clicked.connect( self.__pickProgram ) #------------------------------------------------------------ self.addRow( T_('Hg Program'), self.hg_program, self.browse_program )
def __init__( self, app ): super().__init__( app, T_('Git') ) self.prefs = self.app.prefs.git #------------------------------------------------------------ self.git_program = QtWidgets.QLineEdit() if self.prefs.program is not None: self.git_program.setText( str(self.prefs.program) ) else: # show the default self.git_program.setText( git.Git.GIT_PYTHON_GIT_EXECUTABLE ) self.browse_program = QtWidgets.QPushButton( T_('Browse...') ) self.browse_program.clicked.connect( self.__pickProgram ) self.addRow( T_('Git Program'), self.git_program, self.browse_program )
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, app ): super().__init__( app, T_('Projects') ) if self.app is None: self.prefs = None else: self.prefs = self.app.prefs.projects_defaults self.new_projects_folder = QtWidgets.QLineEdit() if self.prefs.new_projects_folder is not None: self.new_projects_folder.setText( str(self.prefs.new_projects_folder) ) else: # show the default self.new_projects_folder.setText( str(wb_platform_specific.getHomeFolder()) ) self.browse_folder = QtWidgets.QPushButton( T_('Browse...') ) self.browse_folder.clicked.connect( self.__pickFolder ) self.addRow( T_('New projects folder'), self.new_projects_folder, self.browse_folder )
def __init__( self, app ): super().__init__( app, T_('Shell') ) if self.app is None: self.prefs = None else: self.prefs = self.app.prefs.shell terminal_program_list = wb_shell_commands.getTerminalProgramList() file_browser_program_list = wb_shell_commands.getFileBrowserProgramList() self.terminal_program = QtWidgets.QComboBox() self.terminal_program.addItems( terminal_program_list ) self.terminal_init = QtWidgets.QLineEdit( '' ) self.file_browser_program = QtWidgets.QComboBox() self.file_browser_program.addItems( file_browser_program_list ) if self.prefs is not None: self.terminal_program.setCurrentText( self.prefs.terminal_program ) self.terminal_init.setText( self.prefs.terminal_init ) self.file_browser_program.setCurrentText( self.prefs.file_browser ) self.addRow( T_('Terminal Program'), self.terminal_program ) self.addRow( T_('Terminal Init Command'), self.terminal_init ) self.addRow( T_('File Browser Program'), self.file_browser_program )
def __init__( self, app, parent ): self.app = app super().__init__( parent ) self.setWindowTitle( T_('Rename - %s') % (' '.join( app.app_name_parts ),) ) self.old_name = None self.name = QtWidgets.QLineEdit() self.name.textChanged.connect( self.nameTextChanged ) self.ok_button.setEnabled( False ) em = self.fontMetrics().width( 'M' ) self.addRow( T_('Name'), self.name, min_width=em*80 ) self.addButtons()
def __init__( self, app, parent_win, title, name=None ): super().__init__( parent_win ) self.name = name # used for debug self.text_file_name = QtWidgets.QLineEdit() self.text_file_name.setText( title ) self.text_file_name.setReadOnly( True ) self.ed = DiffBodyText( app, self, name=self.name ) v_layout = QtWidgets.QBoxLayout( QtWidgets.QBoxLayout.LeftToRight ) v_layout.addWidget( self.ed.diff_line_numbers ) v_layout.addWidget( self.ed ) h_layout = QtWidgets.QBoxLayout( QtWidgets.QBoxLayout.TopToBottom ) h_layout.addWidget( self.text_file_name ) h_layout.addLayout( v_layout ) self.setLayout( h_layout )
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 read_settings(self): settings = QtCore.QSettings(self._application, self._section) for key in settings.allKeys(): value = settings.value(key) try: # This is required to skip the tab_position key/value this = getattr(self.ui, key) except: continue if isinstance(this, QW.QLineEdit): this.setText(value) elif isinstance(this, QW.QSpinBox): this.setValue(int(value)) elif isinstance(this, QW.QCheckBox): if value in ['false', False, "False"]: this.setChecked(False) else: this.setChecked(True) elif isinstance(this, FileBrowser): this.set_filenames(value) else: print('could not handle : %s' % this) # The last tab position self._tab_pos = settings.value("tab_position", 0, type=int) self.ui.tabs.setCurrentIndex(self._tab_pos)
def get_settings(self): # get all items to save in settings items = {} names = self._get_widget_names() for name in names: widget = getattr(self.ui, name) if isinstance(widget, QW.QLineEdit): value = widget.text() elif isinstance(widget, QW.QSpinBox): value = widget.value() elif isinstance(widget, QW.QCheckBox): value = widget.isChecked() elif isinstance(widget, QW.QSpinBox): value = widget.value() elif isinstance(widget, FileBrowser): value = widget.get_filenames() else: raise NotImplementedError("for developers") items[name] = value items["tab_position"] = self.ui.tabs.currentIndex() return items
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, *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, 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) # Create textbox self.textbox = QLineEdit(self) self.textbox.move(20, 20) self.textbox.resize(280,40) # Create a button in the window self.button = QPushButton('Show text', self) self.button.move(20,80) # connect button to function on_click self.button.clicked.connect(self.on_click) self.show()
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 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) """style is relying on object names so make sure they are set before registering widgets""" self.setObjectName('HubSearch') search_action = QtWidgets.QAction(self) search_action.setObjectName('search_action') close_action = QtWidgets.QAction(self) close_action.setObjectName('close_action') close_action.triggered.connect(self.cancel.emit) close_action.triggered.connect(self.clear) self.addAction(search_action, QtWidgets.QLineEdit.LeadingPosition) self.addAction(close_action, QtWidgets.QLineEdit.TrailingPosition) plexdesktop.style.Style.Instance().widget.register(search_action, 'glyphicons-search') plexdesktop.style.Style.Instance().widget.register(close_action, 'cancel')
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, 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): 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): super(MemNavWidget, self).__init__() self.expr_entry = QtWidgets.QLineEdit() self.esize_entry = QtWidgets.QLineEdit() hbox1 = QtWidgets.QHBoxLayout() hbox1.setContentsMargins(2, 2, 2, 2) hbox1.setSpacing(4) hbox1.addWidget(self.expr_entry) hbox1.addWidget(self.esize_entry) self.setLayout(hbox1) self.expr_entry.returnPressed.connect(self.emitUserChangedSignal) self.esize_entry.returnPressed.connect(self.emitUserChangedSignal)
def __init__(self,file_box=False): QWidget.__init__(self) self.hbox=QHBoxLayout() self.edit=QLineEdit() self.button=QPushButton() self.button.setFixedSize(25, 25) self.button.setText("...") self.hbox.addWidget(self.edit) self.hbox.addWidget(self.button) self.hbox.setContentsMargins(0, 0, 0, 0) self.edit.setStyleSheet("QLineEdit { border: none }"); if file_box==True: self.button.clicked.connect(self.callback_button_click) self.setLayout(self.hbox)
def __init__(self,r,g,b): QWidget.__init__(self) self.r=r self.g=g self.b=b self.hbox=QHBoxLayout() self.edit=QLineEdit() self.button=QPushButton() self.button.setFixedSize(25, 25) self.button.setText("...") self.hbox.addWidget(self.edit) self.hbox.addWidget(self.button) self.hbox.setContentsMargins(0, 0, 0, 0) self.update_color() self.button.clicked.connect(self.callback_button_click) self.setLayout(self.hbox)
def callback_edit(self, file_name,token,widget): if type(widget)==QLineEdit: a=undo_list_class() a.add([file_name, token, inp_get_token_value(self.file_name, token),widget]) inp_update_token_value(file_name, token, widget.text()) elif type(widget)==gtkswitch: inp_update_token_value(file_name, token, widget.get_value()) elif type(widget)==leftright: inp_update_token_value(file_name, token, widget.get_value()) elif type(widget)==gpvdm_select: inp_update_token_value(file_name, token, widget.text()) elif type(widget)==QComboBox: inp_update_token_value(file_name, token, widget.itemText(widget.currentIndex())) elif type(widget)==QComboBoxLang: inp_update_token_value(file_name, token, widget.currentText_english()) elif type(widget)==QColorPicker: inp_update_token_array(file_name, token, [str(widget.r),str(widget.g),str(widget.b)]) elif type(widget)==QChangeLog: a=undo_list_class() a.add([file_name, token, inp_get_token_value(self.file_name, token),widget]) inp_update_token_array(file_name, token, widget.toPlainText().split("\n")) help_window().help_set_help(["document-save-as","<big><b>Saved to disk</b></big>\n"]) self.changed.emit()
def init_ui(self): self.layout_inputs = QVBoxLayout() self.setLayout(self.layout_inputs) for i in range(self.amount): value = QLineEdit() value.textChanged.connect(self.keep_valid) # value.textChanged.connect(self.parent.input_changed) value.setText('0') value.setInputMask('9999999') value.setCursorPosition(0) self.inputs.append(value) self.layout_inputs.addWidget(value) l = QVBoxLayout() l.addSpacing(1) l.addStretch(-1) self.layout_inputs.addLayout(l)
def update_tab(self, amount): if amount>self.amount: for i in range(amount-self.amount): value = QLineEdit() value.textChanged.connect(self.keep_valid) # value.textChanged.connect(self.parent.input_changed) value.setText('0') value.setInputMask('9999999') value.setCursorPosition(0) self.inputs.append(value) self.layout_inputs.insertWidget(0,value) else: for i in range(amount,self.amount): self.layout_inputs.removeWidget(self.inputs[-1]) self.inputs[-1].hide() self.inputs[-1].close() self.inputs.remove(self.inputs[-1]) self.amount = amount
def setupUi(self, Window): Window.setObjectName("Window") Window.resize(640, 480) self.verticalLayout = QtWidgets.QVBoxLayout(Window) self.verticalLayout.setObjectName("verticalLayout") self.webView = QtWebKitWidgets.QWebView(Window) self.webView.setUrl(QtCore.QUrl("http://webkit.org/")) self.webView.setObjectName("webView") self.verticalLayout.addWidget(self.webView) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.formLayout = QtWidgets.QFormLayout() self.formLayout.setFieldGrowthPolicy(QtWidgets.QFormLayout.ExpandingFieldsGrow) self.formLayout.setObjectName("formLayout") self.elementLabel = QtWidgets.QLabel(Window) self.elementLabel.setObjectName("elementLabel") self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.elementLabel) self.elementLineEdit = QtWidgets.QLineEdit(Window) self.elementLineEdit.setObjectName("elementLineEdit") self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.elementLineEdit) self.horizontalLayout.addLayout(self.formLayout) self.highlightButton = QtWidgets.QPushButton(Window) self.highlightButton.setObjectName("highlightButton") self.horizontalLayout.addWidget(self.highlightButton) self.verticalLayout.addLayout(self.horizontalLayout) self.elementLabel.setBuddy(self.elementLineEdit) self.retranslateUi(Window) QtCore.QMetaObject.connectSlotsByName(Window)