Replies: 2 comments 4 replies
-
the text never updates/rerenders, even when i force a rereder of the app |
Beta Was this translation helpful? Give feedback.
4 replies
-
I've quickly modified your example which might help your understanding, but I'd recommend having another read of the docs about reactvity. Also notice the use of a worker so request doesn't stop the UI from updating. import asyncio
import random
from textual import work
from textual.app import App, ComposeResult
from textual.reactive import reactive
from textual.widgets import Static
class Status(Static):
current_status = reactive("initializing")
def watch_current_status(self) -> None:
self.update(self.current_status)
def on_mount(self) -> None:
self.get_result()
@work
async def get_result(self) -> None:
await asyncio.sleep(1) # simulate work
self.current_status = "getting results..."
await asyncio.sleep(1) # simulate work
passed = random.choice([True, False])
if passed:
self.current_status = "you passed"
else:
self.current_status = "you failed"
class ExampleApp(App):
def compose(self) -> ComposeResult:
yield Status()
if __name__ == "__main__":
app = ExampleApp()
app.run() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Ive been trying to get reactive texts to update based on the response of a 3rd party Api since 2 days, but the text just never updates. Heres a simple example
Beta Was this translation helpful? Give feedback.
All reactions