Preserving global variables after loading new form

If you open Form2 replacing Form1 with open_form(), then yes, Form1 and all its data is gone.

You can address this problem in two ways:

Keeping the main form alive
You can have one main form with the navigation bar and open the other forms with:

get_open_form().content_panel.clear()
get_open_form().content_panel.add_component(new_panel)

as described here. Then you can do get_open_form().my_tasks from any form you load.

Using a module
Another solution is to create a module and put the global variables in it. Then you can do this from any form:

import Module1

class Form1(Form1Template):
  def __init__(self, **properties):
    self.init_components(**properties)
    print Module1.my_tasks
2 Likes