Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
✨ Example for Textualize/textual#3878
Browse files Browse the repository at this point in the history
  • Loading branch information
davep committed Dec 15, 2023
1 parent 0838300 commit 5eeec1e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions init_override.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""https://github.com/Textualize/textual/issues/3878"""

from textual.app import App, ComposeResult
from textual.reactive import var
from textual.widgets import Label, Log

class SomeWidget(Label):

test_1: var[int] = var(0)
test_2: var[int] = var(0, init=False)

def watch_test_1(self, was: int, into: int) -> None:
self.screen.query_one(Log).write_line(f"test_1 {was} -> {into}")

def watch_test_2(self, was: int, into: int) -> None:
self.screen.query_one(Log).write_line(f"test_2 {was} -> {into}")

class InitOverrideApp(App[None]):

def compose(self) -> ComposeResult:
yield SomeWidget()
yield Log()

def on_mount(self) -> None:
def gndn() -> None:
return
self.watch(self.query_one(SomeWidget), "test_2", gndn)

if __name__ == "__main__":
InitOverrideApp().run()

### init_override.py ends here

0 comments on commit 5eeec1e

Please sign in to comment.