class documentation

class InputEntry(Gtk.Entry): (source)

Known subclasses: zim.gui.widgets.FSPathEntry, zim.gui.widgets.PageEntry

View In Hierarchy

Sub-class of Gtk.Entry with support for highlighting mal-formatted inputs and handles UTF-8 decoding. This class must be used as a generic replacement for Gtk.Entry to avoid UTF-8 issues. (This is enforced by the zim test suite which will throw an error for any module using Gtk.Entry directly.)

The widget has a "valid" state which determines if the content is well formed or not. When the state is invalid the widget will have a red background color. This is used e.g. in dialog response handlers to show the user what widget to modify.

The valid state can be either done manually by calling set_input_valid(), or it can be done automatically by providing a function to check what content is valid. Using a function is recommended because it gives more immediate feedback to the user.

Unknown Field: signal
input-valid-changes (): valid state of the widget changed
Method __init__ Constructor
Method clear Clear the text in the entry
Method do_input_valid_changed Undocumented
Method get_input_valid Get the valid state. @returns: True if the input is valid
Method get_text Get the text from the widget. Like Gtk.Entry.get_text() but with UTF-8 decoding and whitespace stripped. @returns: string
Method set_check_func Set a function to check whether input is valid or not @param check_func: the function
Method set_icon Add an icon in the entry widget behind the text
Method set_icon_to_clear Adds a "clear" icon in the entry widget
Method set_input_valid No summary
Method update_input_valid Undocumented
Constant ERROR_COLOR Undocumented
Class Variable __gsignals__ Undocumented
Instance Variable allow_empty Undocumented
Instance Variable allow_whitespace Undocumented
Instance Variable check_func Undocumented
Instance Variable show_empty_invalid Undocumented
Instance Variable _input_valid Undocumented
Instance Variable _normal_color Undocumented
def __init__(self, check_func=None, allow_empty=True, show_empty_invalid=False, placeholder_text=None, allow_whitespace=False): (source)
Constructor
Parameters
check_funca function to check input is valid. This function will be called with the current text as argument and should return True if this text is a valid input.
allow_emptyif False an empty string is considered invalid input
show_empty_invalidif True a red background is also shown when the entry is still empty, if False the background is kept normal even if the empty input is invalid. Without this option a whole input form would start in red color, which looks bad.
placeholder_texttext to show in the widget when it is empty and does not have focus, text will be shown in a color different from normal text and disappear when the user selects the widget. Used to set hints on the usage of the widget.
allow_whitespaceif True allow trailing whitespace or even string containing only whitespace. If False all whitespace is stripped.
def clear(self): (source)
Clear the text in the entry
def do_input_valid_changed(self): (source)

Undocumented

def get_input_valid(self): (source)
Get the valid state.
Returns
True if the input is valid
def get_text(self): (source)
Get the text from the widget. Like Gtk.Entry.get_text() but with UTF-8 decoding and whitespace stripped.
Returns
string
def set_check_func(self, check_func): (source)
Set a function to check whether input is valid or not
Parameters
check_functhe function
def set_icon(self, icon, cb_func, tooltip=None): (source)
Add an icon in the entry widget behind the text
Parameters
iconthe icon as stock ID
cb_functhe callback when the icon is clicked; the callback will be called without any arguments
tooltiptooltip text for the icon
Returns
True if successfull, False if not supported by Gtk version
Unknown Field: todo
add argument to set tooltip on the icon
def set_icon_to_clear(self): (source)

Adds a "clear" icon in the entry widget

This method calls set_icon() with the right defaults for a stock "Clear" icon. In addition it makes the icon insensitive when there is no text in the entry. Clicking the icon will clear the entry.

Returns
True if successfull, False if not supported by Gtk version
def set_input_valid(self, valid, show_empty_invalid=None): (source)
Set input valid or invalid state
Parameters
validTrue or False
show_empty_invalidif not None change the show_empty_invalid attribute
def update_input_valid(self): (source)
ERROR_COLOR: str = (source)

Undocumented

Value
'#EF7F7F'
__gsignals__ = (source)

Undocumented

allow_empty = (source)

Undocumented

allow_whitespace = (source)

Undocumented

check_func = (source)

Undocumented

show_empty_invalid = (source)

Undocumented

_input_valid = (source)

Undocumented

_normal_color = (source)

Undocumented