Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 如何在QLineEdit中隐藏密码_Python 2.7_Passwords_Pyside_Qlineedit - Fatal编程技术网

Python 2.7 如何在QLineEdit中隐藏密码

Python 2.7 如何在QLineEdit中隐藏密码,python-2.7,passwords,pyside,qlineedit,Python 2.7,Passwords,Pyside,Qlineedit,要隐藏由“*”键入的密码。但是密码显示为原始文本 class Form(QDialog): def __init__(self, parent = None): super(Form,self).__init__(parent) self.usernamelabel = QLabel("Username : ") self.passwordlabel = QLabel("Password : ") self.usernam

要隐藏由“*”键入的密码。但是密码显示为原始文本

class Form(QDialog):
    def __init__(self, parent = None):
        super(Form,self).__init__(parent)

        self.usernamelabel = QLabel("Username : ")
        self.passwordlabel = QLabel("Password : ")
        self.username = QLineEdit()
        self.password = QLineEdit()
        self.okbutton = QPushButton("Login")
        self.username.setPlaceholderText("Enter Username Here")
        self.password.setPlaceholderText("Enter Password Here")

        layout = QGridLayout()
        layout.addWidget(self.usernamelabel,0,0)
        layout.addWidget(self.passwordlabel,1,0)
        layout.addWidget(self.username,0,1)
        layout.addWidget(self.password,1,1)
        layout.addWidget(self.okbutton)
        self.setLayout(layout)

QLineEdit类具有允许您控制其文本显示方式的属性。要仅显示星号(
*
),请执行以下操作:

self.password = QLineEdit()
self.password.setEchoMode(QLineEdit.Password)
...
output = self.password.text()
附言:

要设置不同的密码字符,可以使用此样式表属性:

self.password.setStyleSheet('lineedit-password-character: 9679')

该数字是一个unicode代码点,在本例中表示一个黑色圆圈(
)。

这篇文章将帮助您:“self.password=QLineEdit()”我应该在这段代码中修改什么以获得输出?@AniruddhChaudhari
output=self.password.text()
。现在正在工作,兄弟!!还有别的方法吗?像这样的“Self.password=uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu。?介于space@AniruddhChaudhari. 什么方法?(注:如果您认为此答案有用,请接受它-即单击勾号符号)。