some thoughts:
key principle: your form won’t be displayed until __init__ has executed.
__init__
everything in __init__ wil run and then the form will be displayed/loaded to the screen.
(assuming that it is either the main form open_form('Form1') or it has a visible parent self.content_panel.add_component(Form1())
- if your form needs
datawithdata bindingswhen it is visible put these in your__init__method - calling
open_forminside an__init__method will fail- the other form’s init method will execute, but the current form will be displayed afterwards.
- calling
self.call_jswill fail- the form has yet to load (but
anvil.js.call_jswill work for any js function that is already loaded)
- the form has yet to load (but
- timer events only start after
__init__and only when the form is on the screen - if you have a lot of data to load consider moving this out of
__init__- instead get some data that is quick to load,
- start a background task
- check the background task state with a timer event.
form_show
this event is triggered after the __init__ method has executed, and when the form has been loaded onto the screen.
It is also triggered whenever a form reappears, or whenever you do self.visible = True
- put
self.call_jshere - if you
cacheyour forms (likeHashRoutingdoes) use theform_showevent when a formreappears