alfiopuglisi / guietta

https://guietta.readthedocs.io
MIT License
1.96k stars 93 forks source link

How does one hide entered characters #34

Closed MySixSenses closed 3 years ago

MySixSenses commented 3 years ago

Using guietta, a simple password application would look like

from guietta import _, Gui, Quit
gui = Gui(

  [  'Enter Username:', '__username__'  , _ , _,  ['Login'] ],
  [  'Enter Password:'  , '__password__' ,  _  ,    _   ,       _ ],
  [  "Access Level: " ,    "Access_Level"     ,  _  ,    _   ,      Quit      ]
)
with gui.Login:
    if gui.username == "Username" and gui.password == "Password":
        gui.Access_Level = "Admin"
    else:
        gui.Access_Level = "Incorrect Login Entered"
gui.run()

The only problem is that the password is obvious to everyone. Is there any way to hide it?

alfiopuglisi commented 3 years ago

If you mean hiding the characters from the GUI display, currently guietta does not support password fields directly. You need to access the widget using the gui.widgets dictionary and modify it using the QT methods:

from guietta import _, Gui, Quit, QLineEdit
...
gui.widgets['password'].setEchoMode(QLineEdit.Password)

If instead you mean that the password is plainly visible in the code, there isn't much I can do about that :) You might read it from some file, or apply code obfuscation techniques.

MySixSenses commented 3 years ago

Thanks. Fixed