Pass data back to main form

If you are using the Material design and putting new forms inside its content panel (a typical setup), you can always reach back to the open form (i.e., main), by using get_open_form().

For example,

# anywhere in your app
# "some_function" is defined on the main form
get_open_form().some_function() 

Another helpful technique is to store data using the tag property. For example, you could “stick” data to the main form and get/set it from anywhere in your app as follows:

# in main form
self.tag.place_where_I_hide_things='treasure'

# from anywhere in your app
treasure=get_open_form().tag.place_where_I_hide_things

Lastly, in case it is helpful, when you create an new instance of a form, you can pass variables along to its constructor as follows:

# in main
from form2 import form2
.
.
.

# create instance of a form2 and pass a variable
# can be positional or keyword args
# stick a reference to form2 on main if you need to
self.tag.form2=form2(foo=bar) 

foo can then be accessed in the init of form2. For example:

# in init of form2
.
.
.
foo=properties['foo']

Please see here and here for more discussion. There are likely similar posts as well. These are the approaches that were particularly helpful to me and I hope they help you too.

2 Likes