mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
36 lines
818 B
Python
36 lines
818 B
Python
from textual.app import App, ComposeResult
|
|
|
|
from textual.containers import Container
|
|
from textual.widget import Widget
|
|
from textual.widgets import Static
|
|
|
|
|
|
class MountWidget(Widget):
|
|
def on_mount(self) -> None:
|
|
print("Widget mounted")
|
|
|
|
|
|
class MountContainer(Container):
|
|
def compose(self) -> ComposeResult:
|
|
yield Container(MountWidget(id="bar"))
|
|
|
|
def on_mount(self) -> None:
|
|
bar = self.query_one("#bar")
|
|
print("MountContainer got", bar)
|
|
|
|
|
|
class MountApp(App):
|
|
def compose(self) -> ComposeResult:
|
|
yield MountContainer(id="foo")
|
|
|
|
def on_mount(self) -> None:
|
|
foo = self.query_one("#foo")
|
|
print("foo is", foo)
|
|
static = self.query_one("#bar")
|
|
print("App got", static)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = MountApp()
|
|
app.run()
|