class InputEntry(Gtk.Entry): (source)
Known subclasses: zim.gui.widgets.FSPathEntry
, zim.gui.widgets.PageEntry
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 |
zim.gui.widgets.FSPathEntry
, zim.gui.widgets.PageEntry
Parameters | |
check_func | a 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_empty | if False an empty string is considered invalid input |
show_empty_invalid | if 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_text | text 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_whitespace | if True allow trailing whitespace or even string containing only whitespace. If False all whitespace is stripped. |
Returns | |
string |
Parameters | |
icon | the icon as stock ID |
cb_func | the callback when the icon is clicked; the callback will be called without any arguments |
tooltip | tooltip 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 |
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 |
Parameters | |
valid | True or False |
show_empty_invalid | if not None change the show_empty_invalid attribute |