SlashedApp
Base classes¶
| Name | Children | Inherits |
|---|---|---|
| App textual.app The base class for Textual Applications. |
||
| Generic typing Abstract base class for generic types. |
â‹” Inheritance diagram¶
graph TD
1346404068["app.SlashedApp"]
3799205450["app.App"]
3481597255["typing.Generic"]
2751680898["builtins.object"]
3946681048["dom.DOMNode"]
53685856["message_pump.MessagePump"]
3799205450 --> 1346404068
3481597255 --> 3799205450
2751680898 --> 3481597255
3946681048 --> 3799205450
53685856 --> 3946681048
2751680898 --> 53685856
3481597255 --> 1346404068
🛈 DocStrings¶
Bases: App[TResult]
Base app with slash command support.
This app provides slash command functionality with optional typed context data. Commands can access the context data through self.context.get_data().
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
TContext
|
Type of the command context data. When using typed context, access it via self.context.get_data() to get proper type checking. |
required | |
TResult
|
Type of value returned by app.run(). Use None if the app doesn't return anything. |
required |
Example
Source code in src/slashed/textual_adapter/app.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
__init__
¶
__init__(
store: CommandStore | None = None,
data: TContext | None = None,
commands: list[type[SlashedCommand] | BaseCommand] | None = None,
*args: Any,
**kwargs: Any,
) -> None
Initialize app with command store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
TContext | None
|
Optional context data |
None
|
commands
|
list[type[SlashedCommand] | BaseCommand] | None
|
Optional list of commands to register |
None
|
store
|
CommandStore | None
|
Optional command store (creates new one if not provided) |
None
|
*args
|
Any
|
Arguments passed to textual.App |
()
|
**kwargs
|
Any
|
Keyword arguments passed to textual.App |
{}
|
Source code in src/slashed/textual_adapter/app.py
bind_output
¶
Bind an output stream to a widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_id
|
str
|
ID for this output stream |
required |
widget_query
|
str
|
CSS query to find the target widget |
required |
default
|
bool
|
Whether this is the default output |
False
|
Source code in src/slashed/textual_adapter/app.py
command_input
classmethod
¶
command_input(
input_id: str,
) -> Callable[[Callable[[Any, str], Awaitable[None]]], Callable[[Any, str], Awaitable[None]]]
Register an Input widget to handle commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_id
|
str
|
ID of the Input widget that should handle commands |
required |
Example
Source code in src/slashed/textual_adapter/app.py
get_suggester
¶
get_suggester() -> SlashedSuggester
on_input_submitted
async
¶
Handle input submission.