Skip to content
Discussion options

You must be logged in to vote

I should also have mentioned that you were also sort of violating the rule of doing UI-based things in a non-thread-safe way; so your code will run if you write it like this:

from textual import work
from textual.app import App
from textual.widgets import Static, DataTable


class MyApp(App):
    def compose(self):
        self.start_work()
        yield Static('HELLO')

    @work(exclusive=True, thread=True)
    def start_work(self):
        dt = DataTable()
        self.call_from_thread(dt.add_column, 'foo')
        self.call_from_thread(
            lambda: self.mount(Static('DONE!'))
        )


if __name__ == '__main__':
    app = MyApp()
    app.run()

(note adding the column in a th…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@davep
Comment options

Answer selected by gubenkoved
@gubenkoved
Comment options

@davep
Comment options

@gubenkoved
Comment options

@davep
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3926 on December 24, 2023 23:12.