The client repl imports the anvil name space.
If you want to access live elements that are on the screen you’ll always have to start from get_open_form()
and work your way down the component hierarchy.
New session:
>>> f = get_open_form() # or anvil.get_open_form()
>>> f
<my_project.Form1 object>
>>> b = f.button_1
>>> b
<Button object>
>>> b.text = "foo"
New session:
>>> f = get_open_form() # or anvil.get_open_form()
>>> f.content_panel.get_components()[0] # get the form loaded into the conent_panel
<my_project.Form2 object>
>>> g = _ # last stored repl value
>>> g
<my_project.Form2 object>
If you want to import a module, you can’t do relative imports. Instead you’ll need to do absolute imports.
New session:
>>> import my_project.Module1 as m
>>> m.my_func()
1
>>> _ # last stored repl value
1
This means you can access global variables if you’ve put them in a module somewhere.
Autocompletion in the client repl is something we’re working on .