Custom dialogs #2763
-
I'm porting an app using another language/gui framework, that is structured as a series of custom dialogs, each dialog followed by a gui-independent action. Each custom dialog consists of a variety of widgets. Each dialog sets or returns values when it is completed and the dialog is closed. I suppose creating such custom dialogs in Toga is possible, perhaps based on Window (?), but I'm not sure what such an implementation would look like. Any suggestions, pointers, or examples? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Your instinct is correct - the best approach at present would be an instance of Window. Create the instance of Window, possibly with If you want, you can wrap up your custom dialog as a subclass of Window; for extra bonus points, you can make the subclass
Displaying the dialog can then be triggered with:
This will show the dialog, then wait for the OK button to be pressed; when it is, the print statement will execute. |
Beta Was this translation helpful? Give feedback.
-
unfortunately this doesn't work on ios as it doesn't support secondary windows. |
Beta Was this translation helpful? Give feedback.
Your instinct is correct - the best approach at present would be an instance of Window.
Create the instance of Window, possibly with
closable=False
and/orresizable=False
(to ensure that the user can't dismiss the window, or make it a weird size). Add window content matching your widget's input requirement, adding an "OK" button (or whatever acceptance mechanism you want) to the bottom of the window. Add a handler to the OK button that does whatever acceptance handling is required, plus possibly invokes close on the window. Show the window withwindow.show()
.If you want, you can wrap up your custom dialog as a subclass of Window; for extra bonus points, you can make the subclass
await
abl…