1 Attachment(s)
what's wrong with my setEchoMode code
I create a QLineEdit in PyQt, and i want to hide or show the charactor of password, so i use the code below
Here is my login_ui py file Attachment 11205, you can use it to test my code within the py or import it from other py.
Code:
#in the init function, ck_pwd and ck_pay_pwd are QCheckBox, password and pay_password are QLineEdit
def init(self):
QtCore.
QObject.
connect(self.
login_ui.
ck_pwd, QtCore.
SIGNAL("stateChanged(int)"), lambda
: self.
show_or_hide_pass(self.
login_ui.
password)) QtCore.
QObject.
connect(self.
login_ui.
ck_pay_pwd, QtCore.
SIGNAL("stateChanged(int)"), lambda
: self.
show_or_hide_pass(self.
login_ui.
pay_password))
def show_or_hide_pass(self, password_obj):
if password_obj.
EchoMode()!=QtGui.
QLineEdit.
Normal: print 'normal'
password_obj.
setEchoMode(QtGui.
QLineEdit.
Normal) else:
print 'password'
password_obj.
setEchoMode(QtGui.
QLineEdit.
Password)
but in the function show_or_hide_pass, the password_obj.EchoMode() always be the 0 (value of QtGui.QLineEdit.Normal), it doesn't make any sense.
what's wrong with my code, Is there somebody can help?
Re: what's wrong with my setEchoMode code
Line 8, the property name is echoMode() not EchoMode().
Re: what's wrong with my setEchoMode code
oh, what a fuck!!
that is the problem.
thanks a lot
Re: what's wrong with my setEchoMode code
Perhaps PyChecker or Pylint would have flagged this for you.