77
88Textual Inputs is a collection of input widgets for the [ Textual] ( https://github.com/willmcgugan/textual ) TUI framework.
99
10- ⚠️ This library is experimental and its interfaces are likely
11- to change, much like the underlying Textual library.
10+ > ⚠️ This library is experimental and its interfaces will change. While
11+ > Textual Inputs is pre-alpha please pin your projects to the minor release
12+ > number to avoid breaking changes. For example: textual-inputs=0.2.\*
1213
13- ## Supported Widgets
14+ ---
15+
16+ ## News
17+
18+ ### v0.2.4
19+
20+ Adds support for customizing the message handler names for on change and
21+ on focus events emitted by the inputs. Under the hood this will generate
22+ a ` Message ` class with the appropriate name for Textual to send it to
23+ the handler name provided. You'll then want add the handler to the input's
24+ parent or the App instance. If you opt not to customize these handlers,
25+ their values will be the default ` handle_input_on_change ` and ` handle_input_on_focus ` .
26+ See ` examples/simple_form.py ` for a working example.
27+
28+ ``` python
29+ email = TextInput(name = " email" , title = " Email" )
30+ email.on_change_handler_name = " handle_email_on_change"
31+ email.on_focus_handler_name = " handle_email_on_focus"
32+ ```
33+
34+ ---
35+
36+ ## Quick Start
37+
38+ Installation
39+
40+ ``` bash
41+ python -m pip install textual-inputs=0.2.*
42+ ```
43+
44+ To use Textual Inputs
45+
46+ ``` python
47+ from textual_inputs import TextInput, IntegerInput
48+ ```
49+
50+ Checkout the [ examples] ( https://github.com/sirfuzzalot/textual-inputs/tree/main/examples ) for reference.
51+
52+ ``` bash
53+ git clone https://github.com/sirfuzzalot/textual-inputs.git
54+ cd textual-inputs
55+ python3 -m venv venv
56+ source venv/bin/activate
57+ python -m pip install -e .
58+ python examples/simple_form.py
59+ ```
60+
61+ ---
62+
63+ ## Widgets
1464
1565### TextInput 🔡
1666
@@ -30,25 +80,105 @@ to change, much like the underlying Textual library.
3080- controls: arrow right/left, home, end, delete, backspace/ctrl+h, escape
3181- emits - InputOnChange, InputOnFocus messages
3282
33- ## Quick Start
83+ ---
3484
35- ``` bash
36- python -m pip install textual-inputs
37- ```
85+ ## API Reference
3886
39- Checkout the [ examples ] ( https://github.com/sirfuzzalot/textual-inputs/tree/main/examples ) for reference .
87+ Textual Inputs has two widgets, here are their attributes .
4088
41- ``` bash
42- git clone https://github.com/sirfuzzalot/textual-inputs.git
43- cd textual-inputs
44- python3 -m venv venv
45- source venv/bin/activate
46- python -m pip install -r requirements.txt
47- python examples/simple_form.py
48- ```
89+ ``` python
90+ class TextInput (Widget ):
91+ """
92+ A simple text input widget.
4993
50- To use Textual Inputs
94+ Args:
95+ name (Optional[str]): The unique name of the widget. If None, the
96+ widget will be automatically named.
97+ value (str, optional): Defaults to "". The starting text value.
98+ placeholder (str, optional): Defaults to "". Text that appears
99+ in the widget when value is "" and the widget is not focused.
100+ title (str, optional): Defaults to "". A title on the top left
101+ of the widget's border.
102+ password (bool, optional): Defaults to False. Hides the text
103+ input, replacing it with bullets.
104+
105+ Attributes:
106+ value (str): the value of the text field
107+ placeholder (str): The placeholder message.
108+ title (str): The displayed title of the widget.
109+ has_password (bool): True if the text field masks the input.
110+ has_focus (bool): True if the widget is focused.
111+ cursor (Tuple[str, Style]): The character used for the cursor
112+ and a rich Style object defining its appearance.
113+ on_change_handler_name (str): name of handler function to be
114+ called when an on change event occurs. Defaults to
115+ handle_input_on_change.
116+ on_focus_handler_name (name): name of handler function to be
117+ called when an on focus event occurs. Defaults to
118+ handle_input_on_focus.
119+
120+ Events:
121+ InputOnChange: Emitted when the contents of the input changes.
122+ InputOnFocus: Emitted when the widget becomes focused.
123+
124+ Examples:
125+
126+ .. code-block:: python
127+
128+ from textual_inputs import TextInput
129+
130+ email_input = TextInput(
131+ name="email",
132+ placeholder="enter your email address...",
133+ title="Email",
134+ )
135+
136+ """
137+ ```
51138
52139``` python
53- from textual_inputs import TextInput, IntegerInput
140+ class IntegerInput (Widget ):
141+ """
142+ A simple integer input widget.
143+
144+ Args:
145+ name (Optional[str]): The unique name of the widget. If None, the
146+ widget will be automatically named.
147+ value (Optional[int]): The starting integer value.
148+ placeholder (Union[str, int, optional): Defaults to "". Text that
149+ appears in the widget when value is "" and the widget is not focused.
150+ title (str, optional): Defaults to "". A title on the top left
151+ of the widget's border.
152+
153+ Attributes:
154+ value (Union[int, None]): the value of the input field
155+ placeholder (str): The placeholder message.
156+ title (str): The displayed title of the widget.
157+ has_focus (bool): True if the widget is focused.
158+ cursor (Tuple[str, Style]): The character used for the cursor
159+ and a rich Style object defining its appearance.
160+ on_change_handler_name (str): name of handler function to be
161+ called when an on change event occurs. Defaults to
162+ handle_input_on_change.
163+ on_focus_handler_name (name): name of handler function to be
164+ called when an on focus event occurs. Defaults to
165+ handle_input_on_focus.
166+
167+ Events:
168+ InputOnChange: Emitted when the contents of the input changes.
169+ InputOnFocus: Emitted when the widget becomes focused.
170+
171+ Examples:
172+
173+ .. code-block:: python
174+
175+ from textual_inputs import IntegerInput
176+
177+ age_input = IntegerInput(
178+ name="age",
179+ placeholder="enter your age...",
180+ title="Age",
181+ )
182+
183+ """
54184```
0 commit comments