Replies: 2 comments 1 reply
-
I notice you don't mention why |
Beta Was this translation helpful? Give feedback.
0 replies
-
so @on(ScreenResume)
def notify_child_widget_about_resuming() -> None
self.query_one(SomeWidget).notify_resumed() is not that promising. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Initially, when I read the description of the
Show
messageI thought that it would allow me to hook on the action of re-showing the widget on the screen below when we exit from another screen (pop_screen), because it appears on the screen again.
There is a logical reason for this behaviour / additional hook to exist and it would simplify many things in multi-screen applications.
That's because there is already
on(Mount)
which can be hooked on when we initially push a new screen with new widgets.What I'm talking about is like the thing, only from the other side.
I also believe that textual should provide as many hooks as possible - this is a very nice feature that allows you to get rid of binding in the code.
Let's consider the case when we have, for example, a list of items on one screen, with a "DELETE" button next to each one. after pressing it, the next screen appears on the stack (let's skip thinking about what should be there and why.. e.g. the delete action confirmation or some extra data should be provided) - then we want that item to be removed (we could hook on this message (posted when other screen pops, and rebuild the desired item Widget)
When the action is successful - we would like to inform the screen below us. A great solution seems to be to use
@on
hooks instead of using callbacks, either through dismiss or passing references and calling methods on them. It is less binding.When we are talking about returning to this screen from several places - instead of placing logic informing this Widget in a strange way if it is placed on the screen below and nested (then I would probably have to
self.app.screen_stack[-2].query(SomeItem)
, becauseself.app.query
does not seem to take into account inactive screens ordismiss
with callback which is also not the perfect solution) in many places - it is enough that in the widget concerned I will handle@on(Show)
(maybe even instead of@on(Mount)
)Beta Was this translation helpful? Give feedback.
All reactions