-
Notifications
You must be signed in to change notification settings - Fork 14
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
Dynamic View and multiple Windows per App #11
Comments
Re: hidden components. I see that this is possible in some way already by using inline condidtionals in the View, e.g. |
I see that the FormDialog uses the undocumented List widget, will look into that some more: |
Here's an example of how to create new windows on the click of a button, and how to close all windows once the main window is closed:
It uses the I think this solution fits well with the design of the rest of the library. However, the way the library handles windows isn't perfect: when the user closes a window that does not have an on_close event defined, the window will disappear, but the internal state will not register that the window is gone. This means that next time render is called, the window will be resurrected. I'm not sure about the best way of handling this inconsistency. The simplest way is to block the usual window closing mechanism, and only close a window when it's not rendered by anything. But I think this is bad default behavior and would result in overhead for almost all situations. The current version will get all the simple cases right, but could result in inconsistencies with multiple windows if the user isn't careful. Do you have any thoughts on how this might be better designed? |
Thanks for the clarification. That example is quite helpful: maybe it can replace the current Window example in the docstrings? Actually, do we even need
For my use cases it will probably work as-is. I agree that blocking the closing event would be a bit ugly. The only thing I can think of right away that might be convenient is to define a |
Is there some way to tell |
Just a heads up that I'm too busy to really look at this, and my original use-case isn't going to happen in the form that I planned. Feel free to close this, or you can leave it open in case there are any takers. I'll definitely recommend that people check out this package if I find anyone looking for simple/reactive UI in python :) |
Apps with multiple windows is supported in v1.5.0 with the WindowPopView Element. |
Related to #10 but hopefully this issue can serve as a more general discussion about handling Apps with multiple Windows.
The first issue I have encountered is that a View cannot contain exclusively Window components. See the snippet in #10 for which the App is not terminated. I think it's because the App is creating a window for its children, however when these are Windows themselves then the root window is "invisible" and can't be closed. Adding any other component to the View resolves this:
The second thing is that I am not quite sure how to go about dynamically managing windows. An example of spawning a window from a button click would be interesting (if it is possible). Then there is also the possibility of dynamic Views where some components could be invisible depending on a conditional...
Lastly, the snippet above creates two windows (one for MyApp, implicitly, and one for the second Label). They can be closed independently. In many cases, it would be desirable to assign one window as the root or parent window. When closed, it should close all of it's children and terminate the App.
As time permits, I'll dig into thee implementations some more and hopefully I can help in some way (even if it's just testing or documentation).
The text was updated successfully, but these errors were encountered: