Link¶
Added in version 0.84.0
A widget to display a piece of text that opens a URL when clicked, like a web browser link.
- Focusable
- Container
Example¶
A trivial app with a link. Clicking the link open's a web-browser—as you might expect!
from textual.app import App, ComposeResult
from textual.widgets import Link
class LabelApp(App):
AUTO_FOCUS = None
CSS = """
Screen {
align: center middle;
}
"""
def compose(self) -> ComposeResult:
yield Link(
"Go to textualize.io",
url="https://textualize.io",
tooltip="Click me",
)
if __name__ == "__main__":
app = LabelApp()
app.run()
Reactive Attributes¶
Name | Type | Default | Description |
---|---|---|---|
text |
str |
"" |
The text of the link. |
url |
str |
"" |
The URL to open when the link is clicked. |
Messages¶
This widget sends no messages.
Bindings¶
The Link widget defines the following bindings:
Key(s) | Description |
---|---|
enter | Open the link in the browser. |
Component classes¶
This widget contains no component classes.
Bases: Static
A simple, clickable link that opens a URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
Text of the link. |
required |
|
str | None
|
A URL to open, when clicked. If |
None
|
|
str | None
|
Optional tooltip. |
None
|
|
str | None
|
Name of widget. |
None
|
|
str | None
|
ID of Widget. |
None
|
|
str | None
|
Space separated list of class names. |
None
|
|
bool
|
Whether the static is disabled or not. |
False
|