textual.widget
This module contains the Widget class, the base class for all widgets.
AwaitMount
¶
BadWidgetName
¶
Bases: Exception
Raised when widget class names do not satisfy the required restrictions.
MountError
¶
Bases: WidgetError
Error raised when there was a problem with the mount request.
PseudoClasses
¶
Bases: NamedTuple
Used for render/render_line based widgets that use caching. This structure can be used as a cache-key.
Widget
¶
Bases: DOMNode
A Widget is the base class for Textual widgets.
See also static for starting point for your own widgets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Widget
|
Child widgets. |
()
|
|
str | None
|
The name of the widget. |
None
|
|
str | None
|
The ID of the widget in the DOM. |
None
|
|
str | None
|
The CSS classes for the widget. |
None
|
|
bool
|
Whether the widget is disabled or not. |
False
|
|
bool
|
Enable content markup? |
True
|
ALLOW_MAXIMIZE
class-attribute
¶
Defines default logic to allow the widget to be maximized.
NoneUse default behavior (Focusable widgets may be maximized)FalseDo not allow widget to be maximizedTrueAllow widget to be maximized
ALLOW_SELECT
class-attribute
¶
Does this widget support automatic text selection? May be further refined with Widget.allow_select.
FOCUS_ON_CLICK
class-attribute
¶
Should focusable widgets be automatically focused on click? Default return value of Widget.focus_on_click.
absolute_offset
instance-attribute
¶
Force an absolute offset for the widget (used by tooltips).
allow_horizontal_scroll
property
¶
Check if horizontal scroll is permitted.
May be overridden if you want different logic regarding allowing scrolling.
allow_maximize
property
¶
Check if the widget may be maximized.
Returns:
| Type | Description |
|---|---|
bool
|
|
allow_select
property
¶
Check if this widget permits text selection.
Returns:
| Type | Description |
|---|---|
bool
|
|
allow_vertical_scroll
property
¶
Check if vertical scroll is permitted.
May be overridden if you want different logic regarding allowing scrolling.
auto_links
class-attribute
instance-attribute
¶
auto_links = Reactive(True)
Widget will highlight links automatically.
border_subtitle
class-attribute
instance-attribute
¶
A title to show in the bottom border (if there is one).
border_title
class-attribute
instance-attribute
¶
A title to show in the top border (if there is one).
can_focus_children
class-attribute
instance-attribute
¶
Widget's children may receive focus.
container_scroll_offset
property
¶
The scroll offset the nearest container ancestor.
container_size
property
¶
The size of the container (parent widget).
Returns:
| Type | Description |
|---|---|
Size
|
Container size. |
container_viewport
property
¶
The viewport region (parent window).
Returns:
| Type | Description |
|---|---|
Region
|
The region that contains this widget. |
content_offset
property
¶
An offset from the Widget origin where the content begins.
Returns:
| Type | Description |
|---|---|
Offset
|
Offset from widget's origin. |
content_region
property
¶
Gets an absolute region containing the content (minus padding and border).
Returns:
| Type | Description |
|---|---|
Region
|
Screen region that contains a widget's content. |
content_size
property
¶
The size of the content area.
Returns:
| Type | Description |
|---|---|
Size
|
Content area size. |
disabled
class-attribute
instance-attribute
¶
disabled = Reactive(False)
Is the widget disabled? Disabled widgets can not be interacted with, and are typically styled to look dimmer.