Lineedit¶
The LineEdit
and MultiLineEdit
widgets provide a way for the user
to input text.
from flexx import app, event, ui
class Example(ui.Widget):
def init(self):
with ui.VBox():
self.line = ui.LineEdit(placeholder_text='type here')
self.l1 = ui.Label(html='<i>when user changes text</i>')
self.l2 = ui.Label(html='<i>when unfocusing or hitting enter </i>')
self.l3 = ui.Label(html='<i>when submitting (hitting enter)</i>')
ui.Widget(flex=1)
@event.reaction('line.user_text')
def when_user_changes_text(self, *events):
self.l1.set_text('user_text: ' + self.line.text)
@event.reaction('line.user_done')
def when_user_is_done_changing_text(self, *events):
self.l2.set_text('user_done: ' + self.line.text)
@event.reaction('line.submit')
def when_user_submits_text(self, *events):
self.l3.set_text('submit: ' + self.line.text)
-
class
flexx.ui.
LineEdit
(*init_args, **kwargs)¶ Inherits from:
Widget
An input widget to edit a line of text.
The
node
of this widget is a text <input>.properties: autocomp, disabled, password_mode, placeholder_text, text
emitters: submit, user_done, user_text
actions: set_autocomp, set_disabled, set_password_mode, set_placeholder_text, set_text
-
autocomp
¶ TupleProp – A tuple/list of strings for autocompletion. Might not work in all browsers.
-
disabled
¶ BoolProp – Whether the line edit is disabled.
-
password_mode
¶ BoolProp – Whether the insered text should be hidden.
-
placeholder_text
¶ StringProp – The placeholder text (shown when the text is an empty string).
-
set_autocomp
(*val)¶ action – Setter for the ‘autocomp’ property.
-
set_disabled
(*val)¶ action – Setter for the ‘disabled’ property.
-
set_password_mode
(*val)¶ action – Setter for the ‘password_mode’ property.
-
set_placeholder_text
(*val)¶ action – Setter for the ‘placeholder_text’ property.
-
set_text
(*val)¶ action – Setter for the ‘text’ property.
-
submit
()¶ emitter – Event emitted when the user strikes the enter or return key (but not when losing focus). Has
old_value
andnew_value
attributes (which are the same).
-
text
¶ StringProp – The current text of the line edit. Settable. If this is an empty string, the placeholder_text is displayed instead.
-
user_done
()¶ emitter – Event emitted when the user is done editing the text, either by moving the focus elsewhere, or by hitting enter. Has
old_value
andnew_value
attributes (which are the same).
-
user_text
(text)¶ emitter – Event emitted when the user edits the text. Has
old_value
andnew_value
attributes.
-
-
class
flexx.ui.
MultiLineEdit
(*init_args, **kwargs)¶ Inherits from:
Widget
An input widget to edit multiple lines of text.
The
node
of this widget is a <textarea>.properties: text
emitters: user_done, user_text
actions: set_text
-
set_text
(*val)¶ action – Setter for the ‘text’ property.
-
text
¶ StringProp – The current text of the multi-line edit. Settable. If this is an empty string, the placeholder_text is displayed instead.
-
user_done
()¶ emitter – Event emitted when the user is done editing the text by moving the focus elsewhere. Has
old_value
andnew_value
attributes (which are the same).
-
user_text
(text)¶ emitter – Event emitted when the user edits the text. Has
old_value
andnew_value
attributes.
-