-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AssertionError
when updating ListView
in a worker
#4958
Comments
Yeah, setting Anyway, you can still make it work in this case: You want to switch off "loading" which will unmount the from textual._work_decorator import work
from textual.app import App, ComposeResult
from textual.widgets import ListView
class MyApp(App[None]):
def compose(self) -> ComposeResult:
yield ListView()
def on_mount(self) -> None:
list_view = self.query_exactly_one(ListView)
list_view.loading = True
self.populate_table()
@work
async def populate_table(self) -> None:
list_view = self.query_exactly_one(ListView)
await list_view.set_loading(False)
await list_view.clear()
await list_view.extend([])
app = MyApp()
app.run() Closing this for now as I've validated the above works, but feel free to let us know if you hit any other problems. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Setting
loading=True
and updatingListView
inside of a worker with an empty list will cause it to raise anAssertionError
withLoadingIndicator
Textual Diagnostics
Versions
Python
|
| Implementation | CPython
|
| Compiler | MSC v.1934 64 bit (AMD64)
|
| Executable | C:\Users\Kevin\AppData\Local\pypoetry\Cache\virtualenvs\listentui-qruDwX8r-py3.11\Scripts\python.exe |
Operating System
Terminal
Rich Console options
The text was updated successfully, but these errors were encountered: