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