pyforms的密码字段?

问题描述:

我的用户界面是用pyforms编写的。pyforms的密码字段?

如何实现密码字段? (EG。而不是'P @ ssW0rd'它会显示'********')。

我发现我可以利用QLineEdit.EchoMode,但不确定如何实现。

在此先感谢!

  • 更新,以反映社会准则
+0

请更新您的问题是一个问题。目前还不清楚你在寻求什么帮助。请在此处查看指导原则:https://*.com/help/how-to-ask并更改您的问题。 – Ben

你可以在你的项目文件夹中添加下列模块ControlPasswordText.py

from pysettings import conf 
from pyforms.Controls import ControlText 

from PyQt4.QtGui import QLineEdit 

class ControlPasswordText(ControlText): 
    def __init__(self, *args, **kwargs): 
     super(ControlPasswordText, self).__init__(*args, **kwargs) 
     self.form.lineEdit.setEchoMode(QLineEdit.Password) 

而且这里是你将如何使用它:

import pyforms 
from pyforms   import BaseWidget 
from pyforms.Controls import ControlText 
from pyforms.Controls import ControlButton 

# Importing the module here 
from ControlPasswordText import ControlPasswordText 

class SimpleExample1(BaseWidget): 

    def __init__(self): 
     super(SimpleExample1,self).__init__('Simple example 1') 

     #Definition of the forms fields 
     self._username  = ControlText('Username') 
     # Using the password class 
     self._password = ControlPasswordText('Password') 


#Execute the application 
if __name__ == "__main__": pyforms.startApp(SimpleExample1) 

结果:

enter image description here

+0

谢谢一堆。正是我在找什么! – CraigJ