當前位置: 首頁>>代碼示例>>Python>>正文


Python QtWidgets.QLineEdit類代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit類的具體用法?Python QLineEdit怎麽用?Python QLineEdit使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了QLineEdit類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    def __init__(self, vcards, keys, parent):
        self.vcards, self.keys = vcards, keys
        super().__init__(parent)

        done = QPushButton("Done", self)
        done.clicked.connect(self.merge_done)

        self.edits = {}
        layout = QGridLayout()
        layout.addWidget(done, 0, 1)
        i = 1
        for key in self.keys:
            if key not in ['REV', 'UID', 'VERSION', 'PRODID']:

                items = set()
                for v in self.vcards.values():
                    if key in v.dict and v.dict[key]:
                        for item in v.dict[key]:
                            items.add(item)
                if items:
                    edit = QLineEdit(self)
                    edit.setText('|'.join(items))
                    layout.addWidget(QLabel(key), i, 0)
                    layout.addWidget(edit, i, 1)
                    self.edits[key] = edit
                    i += 1

        self.setLayout(layout)
開發者ID:nim65s,項目名稱:scripts,代碼行數:28,代碼來源:qtui.py

示例2: Example

class Example(QWidget):
    
    def __init__(self):
        super().__init__()
        
        self.initUI()
        
        
    def initUI(self):      

        self.btn = QPushButton('Dialog', self)
        self.btn.move(20, 20)
        self.btn.clicked.connect(self.showDialog)
        
        self.le = QLineEdit(self)
        self.le.move(130, 22)
        
        self.setGeometry(300, 300, 290, 150)
        self.setWindowTitle('Input dialog')
        self.show()
        
        
    def showDialog(self):
        """ ボタンが押されるとダイアログを出す """

        # input dialogを出す
        text, ok = QInputDialog.getText(self, 'Input Dialog', 
            'Enter your name:')
        
        if ok:
            # QLineEditのオブジェクトにテキストをセット
            self.le.setText(str(text))
開發者ID:minus9d,項目名稱:python_exercise,代碼行數:32,代碼來源:ch05-01-QInputDialog.py

示例3: add_line

 def add_line(self, label, value, row_number, layout):
     layout.addWidget(QLabel(label), row_number, 0)
     log_dir_widget = QLineEdit(value)
     log_dir_widget.setReadOnly(True)
     width = QFontMetrics(QFont()).width(value) * 1.05
     log_dir_widget.setMinimumWidth(width)
     layout.addWidget(log_dir_widget, row_number+1, 0)
開發者ID:jamesabel,項目名稱:latus,代碼行數:7,代碼來源:gui.py

示例4: __init__

 def __init__(self, asm):
     super().__init__()
     self.setWindowTitle('Create area')
     
     area_name = QLabel('Area name')
     area_id = QLabel('Area id')
             
     self.name_edit = QLineEdit()
     self.name_edit.setMaximumWidth(120)
     
     self.id_edit = QLineEdit()
     self.id_edit.setMaximumWidth(120)
     
     # confirmation button
     button_create_area = QPushButton()
     button_create_area.setText('OK')
     button_create_area.clicked.connect(lambda: self.create_area(asm))
     
     # cancel button
     cancel_button = QPushButton()
     cancel_button.setText('Cancel')
     
     # position in the grid
     layout = QGridLayout()
     layout.addWidget(area_name, 0, 0, 1, 1)
     layout.addWidget(self.name_edit, 0, 1, 1, 1)
     layout.addWidget(area_id, 1, 0, 1, 1)
     layout.addWidget(self.id_edit, 1, 1, 1, 1)
     layout.addWidget(button_create_area, 2, 0, 1, 1)
     layout.addWidget(cancel_button, 2, 1, 1, 1)
     self.setLayout(layout)
開發者ID:mintoo,項目名稱:NetDim,代碼行數:31,代碼來源:area_operations.py

示例5: init

    def init(self):

        vbox = QVBoxLayout()
        self.setLayout(vbox)

        text = QLineEdit('0.')
        text.setReadOnly(True)
        vbox.addWidget(text)

        grid = QGridLayout()
        vbox.addLayout(grid)

        names = ['Exit', 'AC', 'DEL', '+/-',
                 '7', '8', '9', '/',
                 '4', '5', '6', '*',
                 '1', '2', '3', '-',
                 '0', '.', '=', '+']

        positions = [(i, j) for i in range(5) for j in range(4)]

        for position, name in zip(positions, names):
            btn = QPushButton(name)
            grid.addWidget(btn, *position)

        self.move(300, 200)
        self.setWindowTitle('Calculator')
        self.show()
開發者ID:thanhhungchu95,項目名稱:python-prj,代碼行數:27,代碼來源:gridlayout.py

示例6: ConfigDialog

class ConfigDialog(QDialog):
    """Dialog class for configuration dialog"""
    def __init__(self, parent=None):
        """Initializes the dialog"""
        super(ConfigDialog, self).__init__(parent)
        self.__config = Config()

        # create form elements
        self.submitButton = QPushButton('&Save')
        ssh_host_label = QLabel('SSH-Host')
        self.sshHostLine = QLineEdit()
        self.sshHostLine.setText(self.__config.get('SSH', 'host'))

        # create form layout
        form_layout = QGridLayout()
        form_layout.addWidget(ssh_host_label, 0, 0)
        form_layout.addWidget(self.sshHostLine, 0, 1)

        # create main layout
        main_layout = QVBoxLayout()
        main_layout.addLayout(form_layout)
        main_layout.addWidget(self.submitButton)
        # connect submit button with submit action
        self.submitButton.clicked.connect(self.__save)
        self.setLayout(main_layout)
        self.setWindowTitle('Preferences')

    def __save(self):
        """Saves the preferences"""
        ssh_host = self.sshHostLine.text()
        self.__config.set('SSH', 'host', ssh_host)
        self.__config.write()
        self.hide()
開發者ID:frmwrk123,項目名稱:oeprint,代碼行數:33,代碼來源:config.py

示例7: setupUi

    def setupUi(self, Furniture_Form):
        layout = QGridLayout(self)
        self.furnitures = []

        if get_all_rooms_number() != []:
            min_room_number = min(get_all_rooms_number())
            max_room_number = max(get_all_rooms_number())
            room_number_label = "Enter room number({0}-{1}):".format(
                                str(min_room_number), str(max_room_number))
        else:
            room_number_label = ''
        self.room_number_label = QLabel(room_number_label)
        self.room_number_line_edit = QLineEdit()
        self.furniture_name_label = QLabel("Name:")
        self.furniture_name_line_edit = QLineEdit()
        self.quality_label = QLabel("Quality")
        self.quality_combo_box = QComboBox()
        self.quality_combo_box.addItem("Excellent")
        self.quality_combo_box.addItem("Good")
        self.quality_combo_box.addItem("Bad")

        layout.addWidget(self.room_number_label, 0, 0)
        layout.addWidget(self.room_number_line_edit, 0, 1)
        layout.addWidget(self.furniture_name_label, 1, 0)
        layout.addWidget(self.furniture_name_line_edit, 1, 1)
        layout.addWidget(self.quality_label, 2, 0)
        layout.addWidget(self.quality_combo_box, 2, 1)

        self.setLayout(layout)
        self.layout().setSizeConstraint(QLayout.SetFixedSize)
開發者ID:esevlogiev,項目名稱:FrontDesk-System,代碼行數:30,代碼來源:add_furniture.py

示例8: set_view

    def set_view(self):
        self.setWindowTitle("QOtpToken")

        vbox = QVBoxLayout(self)
        hbox = QHBoxLayout()
        hbox.addWidget(QLabel("Secret: "))
        self.secret = QLineEdit()
        hbox.addWidget(self.secret)
        vbox.addLayout(hbox)

        hbox = QHBoxLayout()
        self.counter = QSpinBox()
        self.counter.setMinimum(0)
        self.length = QSpinBox()
        self.length.setValue(6)
        self.length.setMinimum(6)
        self.length.setMaximum(8)
        self.generate = QPushButton("Générer")
        hbox.addWidget(QLabel("Compteur: "))
        hbox.addWidget(self.counter)
        hbox.addWidget(QLabel("Taille: "))
        hbox.addWidget(self.length)
        hbox.addWidget(self.generate)
        vbox.addLayout(hbox)

        hbox = QHBoxLayout()
        hbox.addWidget(QLabel("Mot de passe jetable: "))
        self.display = QLineEdit("")
        self.display.setReadOnly(True)
        hbox.addWidget(self.display)
        vbox.addLayout(hbox)
        self.setLayout(vbox)
        pass
開發者ID:lesbeben,項目名稱:m1ssi2013,代碼行數:33,代碼來源:gui_hotp.py

示例9: __init__

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

        # etykiety, pola edycyjne i przyciski ###
        loginLbl = QLabel('Login')
        hasloLbl = QLabel('Hasło')
        self.login = QLineEdit()
        self.haslo = QLineEdit()
        self.przyciski = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
            Qt.Horizontal, self)

        # układ główny ###
        uklad = QGridLayout(self)
        uklad.addWidget(loginLbl, 0, 0)
        uklad.addWidget(self.login, 0, 1)
        uklad.addWidget(hasloLbl, 1, 0)
        uklad.addWidget(self.haslo, 1, 1)
        uklad.addWidget(self.przyciski, 2, 0, 2, 0)

        # sygnały i sloty ###
        self.przyciski.accepted.connect(self.accept)
        self.przyciski.rejected.connect(self.reject)

        # właściwości widżetu ###
        self.setModal(True)
        self.setWindowTitle('Logowanie')
開發者ID:EdwardBetts,項目名稱:python101,代碼行數:27,代碼來源:gui_z3.py

示例10: createEditor

 def createEditor(self, parent, option, index):
     """ Return a QLineEdit for arbitrary representation of a date value in any format.
     """
     editor = QLineEdit(parent)
     date = index.model().data(index, Qt.DisplayRole)
     editor.setText(date.strftime(self.format))
     return editor
開發者ID:marcel-goldschen-ohm,項目名稱:ModelViewPyQt,代碼行數:7,代碼來源:DateTimeEditDelegateQt.py

示例11: __init__

    def __init__(self, page):
        super(TypographicalQuotes, self).__init__(page)

        layout = QGridLayout(spacing=1)
        self.setLayout(layout)
        l = self.languageLabel = QLabel()
        c = self.languageCombo = QComboBox(currentIndexChanged=self.languageChanged)
        l.setBuddy(c)

        self.primaryLabel = QLabel()
        self.secondaryLabel = QLabel()
        self.primaryLeft = QLineEdit(textEdited=self.changed)
        self.primaryRight = QLineEdit(textEdited=self.changed)
        self.secondaryLeft = QLineEdit(textEdited=self.changed)
        self.secondaryRight = QLineEdit(textEdited=self.changed)

        self._langs = ["current", "custom"]
        self._langs.extend(lang for lang in lasptyqu.available() if lang != "C")
        c.addItems(['' for i in self._langs])

        layout.addWidget(self.languageLabel, 0, 0)
        layout.addWidget(self.primaryLabel, 1, 0)
        layout.addWidget(self.secondaryLabel, 2, 0)
        layout.addWidget(self.languageCombo, 0, 1, 1, 2)
        layout.addWidget(self.primaryLeft, 1, 1)
        layout.addWidget(self.primaryRight, 1, 2)
        layout.addWidget(self.secondaryLeft, 2, 1)
        layout.addWidget(self.secondaryRight, 2, 2)

        app.translateUI(self)
開發者ID:stweil,項目名稱:frescobaldi,代碼行數:30,代碼來源:editor.py

示例12: __init__

    def __init__(self, *args):
        super(MyCurrencyBox, self).__init__(*args)
        Lumberjack.info('spawning a << MyCurrencyBox >>')
        self.currencyBoxlayout = QHBoxLayout(self)
        self.currencyBoxlayout.setObjectName("currencyBoxlayout")
        self.currencyLabel = QLabel('€')
        self.euroLineEdit = QLineEdit()
        self.euroLineEdit.setText('0')
        self.euroLineEdit.setAlignment(Qt.AlignRight)
        self.euroLineEdit.setObjectName("euroLineEdit")
        euroValidator = QIntValidator()
        self.euroLineEdit.setValidator(euroValidator)
        self.euroLineEdit.setMaxLength(6)
        self.commaLabel = QLabel(',')
        self.centsLineEdit = QLineEdit()
        self.centsLineEdit.setText('00')
        self.euroLineEdit.setAlignment(Qt.AlignRight)
        self.centsLineEdit.setObjectName("centsLineEdit")
        centsValidator = QIntValidator(0, 99)
        self.centsLineEdit.setValidator(centsValidator)
        self.centsLineEdit.setMaxLength(2)
        spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        spacerItem2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.currencyBoxlayout.addItem(spacerItem1)
        self.currencyBoxlayout.addWidget(self.currencyLabel)
        self.currencyBoxlayout.addWidget(self.euroLineEdit)
        self.currencyBoxlayout.addWidget(self.commaLabel)
        self.currencyBoxlayout.addWidget(self.centsLineEdit)
        self.currencyBoxlayout.addItem(spacerItem2)

        self.centsLineEdit.textChanged.connect(self.on_text_input)
        self.euroLineEdit.textChanged.connect(self.on_text_input)
開發者ID:MazeFX,項目名稱:pat,代碼行數:32,代碼來源:myWidgets.py

示例13: __init__

 def __init__(self, parent, attribut, editable=False):
     QLineEdit.__init__(self, parent)
     self.setMinimumWidth(300)
     self.parent = parent
     self.attribut = attribut
     self.setReadOnly(not editable)
     self.actualiser()
開發者ID:wxgeo,項目名稱:geophar,代碼行數:7,代碼來源:proprietes_objets.py

示例14: __init__

 def __init__(self, graph_type, controller):
     super().__init__()
     self.controller = controller
     self.graph_type = graph_type
     self.setWindowTitle('Graph generation')
     
     layout = QGridLayout()
     self.node_subtype_list = QObjectComboBox()
     self.node_subtype_list.addItems(node_name_to_obj)
     
     number_of_nodes = QLabel('Nodes')
     self.nodes_edit = QLineEdit()
     self.nodes_edit.setMaximumWidth(120)
     
     if graph_type in ('kneser', 'petersen'):
         number_of_subset = QLabel('Subsets')
         self.subset_edit = QLineEdit()
         self.subset_edit.setMaximumWidth(120)
     
     # confirmation button
     confirmation_button = QPushButton(self)
     confirmation_button.setText('OK')
     confirmation_button.clicked.connect(self.confirm)
     
     layout.addWidget(self.node_subtype_list, 0, 0, 1, 2)
     layout.addWidget(number_of_nodes, 1, 0, 1, 1)
     layout.addWidget(self.nodes_edit, 1, 1, 1, 1)
     if graph_type in ('kneser', 'petersen'):
         layout.addWidget(number_of_subset, 2, 0, 1, 1)
         layout.addWidget(self.subset_edit, 2, 1, 1, 1)
     layout.addWidget(confirmation_button, 3, 0, 1, 2)
     self.setLayout(layout)
開發者ID:mintoo,項目名稱:NetDim,代碼行數:32,代碼來源:graph_dimension.py

示例15: RenameDialog

class RenameDialog(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowModality(Qt.WindowModal)
        self.setWindowTitle(self.tr("Rename…"))

        nameLabel = QLabel(self.tr("Name:"), self)
        self.nameEdit = QLineEdit(self)
        self.nameEdit.setFocus(True)

        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)

        layout = QGridLayout(self)
        l = 0
        layout.addWidget(nameLabel, l, 0)
        layout.addWidget(self.nameEdit, l, 1, 1, 3)
        l += 1
        layout.addWidget(buttonBox, l, 3)
        self.setLayout(layout)

    @classmethod
    def getNewName(cls, parent, name=None):
        dialog = cls(parent)
        dialog.nameEdit.setText(name)
        dialog.nameEdit.selectAll()
        result = dialog.exec_()
        name = dialog.nameEdit.text()
        return (name, result)
開發者ID:anthrotype,項目名稱:trufont,代碼行數:30,代碼來源:glyphDialogs.py


注:本文中的PyQt5.QtWidgets.QLineEdit類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。