Search code examples
pythonuser-interfacepasswordsfiremonkey

How to create a masked password box in a Python FMX GUI app?


I'm making an app using DelphiFMX GUI library for Python. I need to have a component where I can enter a password and have that password masked. Sure I can use an Edit component, but then the password is in plain text and not masked.

How do I mask a password in an Edit component or is there a component specifically for passwords?


Solution

  • Using an Edit component is actually the correct way. There's a Password boolean property that you simply need to set to True and it'll work then:

    self.myPasswordBox.Password = True
    

    Python GUI Password Box

    Here's the full code I used to create the Edit:

    self.myPasswordBox = Edit(self)
    self.myPasswordBox.Parent = self
    self.myPasswordBox.Align = "Center"
    self.myPasswordBox.Width = 250
    self.myPasswordBox.Password = True # Make it a password box that is masked