Returning to a startup module

As @stefano.menci mentions… I don’t think it’s possible to use open_form on a module.

Here’s an option though…

StartupModule

import anvil.users
from anvil import open_form

def startup():
  if not anvil.users.get_user():
    open_form('LoginForm')
  else:
    open_form("MainForm")
    

if __name__ == "__main__":
  startup()

Then when you want to use it again just import the function… This way you keep the startup logic in a Module and can reuse the code later.

def signout_button_click(self, **event_args):
  from ..StartupModule import startup
  startup()

7 Likes