:right-sidebar: True PasswordEntry =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: PasswordEntry(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget`, :class:`~gi.repository.Gtk.Editable` A single-line text entry widget for entering passwords and other secrets. .. image:: https://docs.gtk.org/gtk4/password-entry.png It does not show its contents in clear text, does not allow to copy it to the clipboard, and it shows a warning when Caps Lock is engaged. If the underlying platform allows it, ``GtkPasswordEntry`` will also place the text in a non-pageable memory area, to avoid it being written out to disk by the operating system. Optionally, it can offer a way to reveal the contents in clear text. ``GtkPasswordEntry`` provides only minimal API and should be used with the :obj:`~gi.repository.Gtk.Editable` API. CSS Nodes -------------------------------------------------------------------------------- .. code-block:: :dedent: entry.password ╰── text ├── image.caps-lock-indicator ┊ ``GtkPasswordEntry`` has a single CSS node with name entry that carries a .passwordstyle class. The text Css node below it has a child with name image and style class .caps-lock-indicator for the Caps Lock icon, and possibly other children. Accessibility -------------------------------------------------------------------------------- ``GtkPasswordEntry`` uses the :obj:`~gi.repository.Gtk.AccessibleRole.text_box` role. Constructors ------------ .. rst-class:: interim-class .. class:: PasswordEntry :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.Widget Creates a ``GtkPasswordEntry``\. Methods ------- .. rst-class:: interim-class .. class:: PasswordEntry :no-index: .. method:: get_extra_menu() -> ~gi.repository.Gio.MenuModel | None Gets the menu model set with :func:`~gi.repository.Gtk.PasswordEntry.set_extra_menu`. .. method:: get_show_peek_icon() -> bool Returns whether the entry is showing an icon to reveal the contents. .. method:: set_extra_menu(model: ~gi.repository.Gio.MenuModel | None = None) -> None Sets a menu model to add when constructing the context menu for ``entry``\. :param model: a ``GMenuModel`` .. method:: set_show_peek_icon(show_peek_icon: bool) -> None Sets whether the entry should have a clickable icon to reveal the contents. Setting this to :const:`False` also hides the text again. :param show_peek_icon: whether to show the peek icon Properties ---------- .. rst-class:: interim-class .. class:: PasswordEntry :no-index: .. attribute:: props.activates_default :type: bool Whether to activate the default widget when Enter is pressed. .. attribute:: props.extra_menu :type: ~gi.repository.Gio.MenuModel A menu model whose contents will be appended to the context menu. .. attribute:: props.placeholder_text :type: str The text that will be displayed in the ``GtkPasswordEntry`` when it is empty and unfocused. .. attribute:: props.show_peek_icon :type: bool Whether to show an icon for revealing the content. Signals ------- .. rst-class:: interim-class .. class:: PasswordEntry.signals :no-index: .. method:: activate() -> None Emitted when the entry is activated. The keybindings for this signal are all forms of the Enter key.