Package: textual-inputs
Textual Inputs 🔡Textual Inputs is a collection of input widgets for theTextualTUI framework.⚠️ This library is experimental and its interfaces will change. While
Textual Inputs is pre-alpha please pin your projects to the minor release
number to avoid breaking changes. For example: textual-inputs=0.2.*Newsv0.2.6Support for text overflow in TextInputPatch for crash when IntegerInput is empty and backspace is pressed.Quick StartInstallationpython-mpipinstalltextual-inputs~=0.2.6To use Textual Inputsfromtextual_inputsimportTextInput,IntegerInputCheckout theexamplesfor reference.gitclonehttps://github.com/sirfuzzalot/textual-inputs.gitcdtextual-inputs
python3-mvenvvenvsourcevenv/bin/activate
python-mpipinstall-e.
pythonexamples/simple_form.pyWidgetsTextInput 🔡value - stringone line of text with overflow supportplaceholder and title supportpassword mode to hide inputsyntax mode to highlight codesupport for Unicode characterscontrols: arrow right/left, home, end, delete, backspace/ctrl+h, escapeemits - InputOnChange, InputOnFocus messagesIntegerInput 🔢value - integer or Noneplaceholder and title supporttype a number or arrow up/down to increment/decrement the integer.controls: arrow right/left, home, end, delete, backspace/ctrl+h, escapeemits - InputOnChange, InputOnFocus messagesFeaturesOne-Line Syntax HighlightingTextual Inputs takes advantage ofrich's built-in Syntax feature. To
add highlighting to your input text set thesyntaxargument to a language
supported bypygments. Currently this is set to the default theme.⚠️ THIS FEATURE IS LIMITED TO ONE LINE OF TEXTTextInput(name="code",placeholder="enter some python code...",title="Code",syntax="python",)Event HandlersTextual Inputs helps make the event handler process easier by providing
the following convenient properties for inputs.on_change_handler_nameon_focus_handler_nameemail=TextInput(name="email",title="Email")email.on_change_handler_name="handle_email_on_change"email.on_focus_handler_name="handle_email_on_focus"Under the hood setting this attribute this will generate aMessageclass
with the appropriate name for Textual to send it to the handler name provided.
You'll then want add the handler to the input's parent or the App instance.
If you opt not to customize these handlers, their values will be the
defaulthandle_input_on_changeandhandle_input_on_focus. Seeexamples/simple_form.pyfor a working example.API ReferenceTextual Inputs has two widgets, here are their attributes.classTextInput(Widget):"""A simple text input widget.Args:name (Optional[str]): The unique name of the widget. If None, thewidget will be automatically named.value (str, optional): Defaults to "". The starting text value.placeholder (str, optional): Defaults to "". Text that appearsin the widget when value is "" and the widget is not focused.title (str, optional): Defaults to "". A title on the top leftof the widget's border.password (bool, optional): Defaults to False. Hides the textinput, replacing it with bullets.syntax (Optional[str]): the name of the language for syntax highlighting.Attributes:value (str): the value of the text fieldplaceholder (str): The placeholder message.title (str): The displayed title of the widget.has_password (bool): True if the text field masks the input.syntax (Optional[str]): the name of the language for syntax highlighting.has_focus (bool): True if the widget is focused.cursor (Tuple[str, Style]): The character used for the cursorand a rich Style object defining its appearance.on_change_handler_name (str): name of handler function to becalled when an on change event occurs. Defaults tohandle_input_on_change.on_focus_handler_name (name): name of handler function to becalled when an on focus event occurs. Defaults tohandle_input_on_focus.Events:InputOnChange: Emitted when the contents of the input changes.InputOnFocus: Emitted when the widget becomes focused.Examples:.. code-block:: pythonfrom textual_inputs import TextInputemail_input = TextInput(name="email",placeholder="enter your email address...",title="Email",)"""classIntegerInput(Widget):"""A simple integer input widget.Args:name (Optional[str]): The unique name of the widget. If None, thewidget will be automatically named.value (Optional[int]): The starting integer value.placeholder (Union[str, int, optional): Defaults to "". Text thatappears in the widget when value is "" and the widget is not focused.title (str, optional): Defaults to "". A title on the top leftof the widget's border.Attributes:value (Union[int, None]): the value of the input fieldplaceholder (str): The placeholder message.title (str): The displayed title of the widget.has_focus (bool): True if the widget is focused.cursor (Tuple[str, Style]): The character used for the cursorand a rich Style object defining its appearance.on_change_handler_name (str): name of handler function to becalled when an on change event occurs. Defaults tohandle_input_on_change.on_focus_handler_name (name): name of handler function to becalled when an on focus event occurs. Defaults tohandle_input_on_focus.Events:InputOnChange: Emitted when the contents of the input changes.InputOnFocus: Emitted when the widget becomes focused.Examples:.. code-block:: pythonfrom textual_inputs import IntegerInputage_input = IntegerInput(name="age",placeholder="enter your age...",title="Age",)"""ContributingSee theContributing Guide.