PyQt5-QLabel文本輸入框的四種回顯模式

# encoding: utf-8
'''===================================================
@Project -> File : qt5003 -> QLineEditEchoMode.py
@IDE             : qt5003
@Author          : Mr. Batac
@Date            : 2020-03-18 20:49
@Desc            :
======================================================'''


from PyQt5.QtWidgets import *
import sys

class QLineEditEchoModel(QWidget):

    def __init__(self):
        super(QLineEditEchoModel, self).__init__()
        self.initUI()

    def initUI(self):
        """文本輸入框有四種回顯模式"""
        self.setWindowTitle("文本輸入框的回顯模式")
        formLayout = QFormLayout(self)

        normalLineEdit = QLineEdit()

        noEchoLineEdit = QLineEdit()

        passwordEdit  =QLineEdit()

        passwordEchoPOnEditLineEdit = QLineEdit()

        formLayout.addRow("Nomal", normalLineEdit)
        formLayout.addRow("NOEcho",noEchoLineEdit)
        formLayout.addRow("Password", passwordEdit)
        formLayout.addRow("PasswordEchoOnEdit", passwordEchoPOnEditLineEdit)

        normalLineEdit.setPlaceholderText("Normal")
        noEchoLineEdit.setPlaceholderText("NoEcho")
        passwordEdit.setPlaceholderText("Password")
        passwordEchoPOnEditLineEdit.setPlaceholderText("PasswordEchoOnEdit")

        normalLineEdit.setEchoMode(QLineEdit.Normal)
        noEchoLineEdit.setEchoMode(QLineEdit.NoEcho)
        passwordEdit.setEchoMode(QLineEdit.Password)
        passwordEchoPOnEditLineEdit.setEchoMode(QLineEdit.PasswordEchoOnEdit)

        # self.setLayout(formLayout)




if __name__ == '__main__':
    app = QApplication(sys.argv)

    main = QLineEditEchoModel()
    main.show()

    sys.exit(app.exec_())

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章