Skip to content

PasswordEntry

Bases: Field

A password entry field widget with masked input and visibility toggle.

PasswordEntry extends the Field widget to provide password-specific functionality, including character masking and a toggle button to temporarily reveal the password. The widget automatically inserts a visibility toggle button (eye icon) that shows the password while pressed and hides it when released.

Events

  • <<Input>>: Triggered on each keystroke.
  • <<Change>>: Triggered when value changes after commit.
  • <<Valid>>: Triggered when validation passes.
  • <<Invalid>>: Triggered when validation fails.
  • <<Validate>>: Triggered after any validation.

Attributes:

Name Type Description
entry_widget TextEntryPart

The underlying text entry widget.

label_widget Label

The label widget above the entry.

message_widget Label

The message label widget below the entry.

addons dict[str, Widget]

Dictionary of inserted addon widgets by name.

variable Variable

Tkinter Variable linked to entry text.

signal Signal

Signal object for reactive updates.

__init__

__init__(
    master: Master = None,
    value: str = None,
    label: str = None,
    message: str = None,
    show_visibility_toggle: bool = True,
    **kwargs: Unpack[FieldOptions],
)

Initialize a PasswordEntry widget.

Creates a password entry field with character masking and an optional visibility toggle button. The widget automatically masks input characters (default: '•') and provides a button to temporarily reveal the password while pressed.

Parameters:

Name Type Description Default
master Master

Parent widget. If None, uses the default root window.

None
value str

Initial password value to display (masked). Default is None.

None
label str

Optional label text to display above the entry field. If required=True, an asterisk (*) is automatically appended.

None
message str

Optional message text to display below the entry field. Used for hints or help text. Replaced by validation errors when validation fails.

None
show_visibility_toggle bool

If True, displays the visibility toggle button (eye icon) that reveals the password while pressed. Default is True. Can be changed at runtime via configure(show_visibility_toggle=...).

True

Other Parameters:

Name Type Description
show str

Character to mask password input. Default is '•'.

required bool

If True, field cannot be empty.

accent str

Accent token for the focus ring and active border.

bootstyle str

DEPRECATED - Use accent instead.

allow_blank bool

Allow empty input.

cursor str

Cursor style when hovering.

font str

Font for text display.

foreground str

Text color.

initial_focus bool

If True, widget receives focus on creation.

justify str

Text alignment.

show_message bool

If True, displays message area.

padding str

Padding around entry widget.

takefocus bool

If True, widget accepts Tab focus.

textvariable Variable

Tkinter Variable to link with text.

textsignal Signal

Signal object for reactive updates.

width int

Width in characters.

Note

The visibility toggle button uses a press-and-hold interaction. The password is only visible while the button is actively pressed, providing a secure way to verify input without leaving it exposed.