wait_modal strategies when not on the main thread
Phuket2 last edited by
I have a class that inherits from ui.View and a window opens. I have some ui.ButtonItem items in the menu. One of the actions is to call another custom class that inherits from ui.View also. I want this new class to open a window as a modal dialog. After reading the docs, it appears this can't be done unless called from the main thread regardless if you call wait_modal(). Which I can see is true.
So I guess I need to create a work around. I am sure this issue has been encounted before. Is there a std work around that people employ? The idea that comes to mind for me is to set a function in the 'dialog' from the calling class that will be called on will_close() , inspect the variables etc....it seems messy. Any guidance appreciated.
JonB last edited by
search the forums for polymerchm's shield class, or find it on his github as part of chordcalc. this creates a semitransparent "blocker" that goes over your main view, so that you can't interact with it until your "modal" view is ready to be dismissed.
rather than making the view truly modal, you implement a callback. for instance rather than having
# do some stuff v.present() v.wait_modal() result=v['textbox'].text #do something with the result
the pattern looks like
#do some stuff def ok_callback(sender): result=v['textbox'].text #do something with the result v['okbutton'].action=okcallback #create a shield over the root view, then add v as a subview of the shield #or...present v as a popover