-
Notifications
You must be signed in to change notification settings - Fork 815
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
Add remove
attribute to mount
and mount_all
#4133
Comments
I think of the method Wouldn't it make more sense to grow a method |
The thing is that it is not replacing. It's not like we can guarantee the widgets will be mounted in the same place as the "remove" selector. |
In that case, call it self.remove_children(selector="...")
self.mount(widget) looks much better than self.mount(widget, remove="...") The thing with |
Two methods aren't atomic. Which means you would have to wrap both calls in an asyncio Lock, and await them both. You would also need to use async with self.lock:
with self.app.batch_update():
await self.remove_children("*")
await self.mount(widget) That's too much to ask of devs. The |
If you prefer the |
After a discussion in the office. We could combine the locking and batch update in to a single context manager. async with self.batch():
await self.remove_children("*")
await self.mount(widget) That feels a little less clumsy, but it has its own flaw: Namely, that it requires async. You wouldn't be able to have optional awaitables. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
It's common to remove some widgets and add some other widgets. To make this easier, I think we should add a
remove
attribute to the mount methods which accepts a selector and removes those widgets prior to mounting.The remove + mount should be atomic, to avoid flicker (might need to be wrapped in
batch_update
).API would look something like this:
The text was updated successfully, but these errors were encountered: