textual.screen
This module contains the Screen class and related objects.
The Screen class is a special widget which represents the content in the terminal. See Screens for details.
ScreenResultCallbackType
module-attribute
¶
ScreenResultCallbackType = Union[
Callable[[Optional[ScreenResultType]], None],
Callable[[Optional[ScreenResultType]], Awaitable[None]],
]
Type of a screen result callback function.
ScreenResultType
module-attribute
¶
ScreenResultType = TypeVar('ScreenResultType')
The result type of a screen.
HoverWidgets
¶
Bases: NamedTuple
Result of [get_hover_widget_at][textual.screen.Screen.get_hover_widget_at]
ModalScreen
¶
Bases: Screen[ScreenResultType]
A screen with bindings that take precedence over the App's key bindings.
The default styling of a modal screen will dim the screen underneath.
ResultCallback
¶
Bases: Generic[ScreenResultType]
Holds the details of a callback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
MessagePump
|
The object making a request for the callback. |
required |
|
ScreenResultCallbackType[ScreenResultType] | None
|
The callback function. |
required |
|
Future[ScreenResultType] | None
|
A Future to hold the result. |
None
|
Screen
¶
Bases: Generic[ScreenResultType], Widget
The base class for screens.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | None
|
The name of the screen. |
None
|
|
str | None
|
The ID of the screen in the DOM. |
None
|
|
str | None
|
The CSS classes for the screen. |
None
|
ALLOW_IN_MAXIMIZED_VIEW
class-attribute
¶
A selector for the widgets (direct children of Screen) that are allowed in the maximized view (in addition to maximized widget). Or
None to default to App.ALLOW_IN_MAXIMIZED_VIEW
AUTO_FOCUS
class-attribute
¶
A selector to determine what to focus automatically when the screen is activated.
The widget focused is the first that matches the given CSS selector.
Set to None to inherit the value from the screen's app.
Set to "" to disable auto focus.
COMMANDS
class-attribute
¶
COMMANDS = set()
Command providers used by the command palette, associated with the screen.
Should be a set of command.Provider classes.
CSS
class-attribute
¶
Inline CSS, useful for quick scripts. Rules here take priority over CSS_PATH.
Note
This CSS applies to the whole app.
CSS_PATH
class-attribute
¶
File paths to load CSS from.
Note
This CSS applies to the whole app.
ESCAPE_TO_MINIMIZE
class-attribute
¶
Use escape key to minimize (potentially overriding bindings) or None to defer to App.ESCAPE_TO_MINIMIZE.
HORIZONTAL_BREAKPOINTS
class-attribute
instance-attribute
¶
Horizontal breakpoints, will override App.HORIZONTAL_BREAKPOINTS if not None.
SUB_TITLE
class-attribute
¶
A class variable to set the default sub-title for the screen.
This overrides the app sub-title. To update the sub-title while the screen is running, you can set the sub_title attribute.
TITLE
class-attribute
¶
A class variable to set the default title for the screen.
This overrides the app title. To update the title while the screen is running, you can set the title attribute.
VERTICAL_BREAKPOINTS
class-attribute
instance-attribute
¶
Vertical breakpoints, will override App.VERTICAL_BREAKPOINTS if not None.
active_bindings
property
¶
Get currently active bindings for this screen.
If no widget is focused, then app-level bindings are returned. If a widget is focused, then any bindings present in the screen and app are merged and returned.
This property may be used to inspect current bindings.
Returns:
| Type | Description |
|---|---|
dict[str, ActiveBinding]
|
A map of keys to a tuple containing (NAMESPACE, BINDING, ENABLED). |
bindings_updated_signal
instance-attribute
¶
bindings_updated_signal = Signal(self, 'bindings_updated')
A signal published when the bindings have been updated
layers
property
¶
maximized
class-attribute
instance-attribute
¶
The currently maximized widget, or None for no maximized widget.
screen_layout_refresh_signal
instance-attribute
¶
screen_layout_refresh_signal = Signal(
self, "layout-refresh"
)
The signal that is published when the screen's layout is refreshed.
selections
class-attribute
instance-attribute
¶
Map of widgets and selected ranges.
stack_updates
class-attribute
instance-attribute
¶
An integer that updates when the screen is resumed.
sub_title
class-attribute
instance-attribute
¶
Screen sub-title to override the app sub-title.
text_selection_started_signal
instance-attribute
¶
text_selection_started_signal = Signal(
self, "selection_started"
)
A signal published when text selection has started.
action_dismiss
async
¶
action_dismiss(result=None)
A wrapper around dismiss that can be called as an action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ScreenResultType | None
|
The optional result to be passed to the result callback. |
None
|
arrange
¶
arrange(size, _optimal=False)
Arrange children.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Size
|
Size of container. |
required |
|
Ignored on screen. |
required |
Returns:
| Type | Description |
|---|---|
DockArrangeResult
|
Widget locations. |
can_view_entire
¶
can_view_entire(widget)
Check if a given widget is fully within the current screen.
Note: This doesn't necessarily equate to a widget being visible. There are other reasons why a widget may not be visible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Widget
|
A widget. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|