But instead of using forms inside the same package like in this example (https://anvil.works/build#app:IWOOQFYZCSFPOIU5), I want to use a form called ‘GUI’ from an external package called ‘_1_GGT’.
The first that came up to my mind, is to set up the dependecies from source app ‘dhbw-stuttgart’ to ‘1_GGT’ and package name ‘_1_GGT’ in order that ‘dhbw-stuttgart’ can see ‘1_GGT’.
Then I followed the instructions from the Docs above. Here is slightly adapted client code for ‘dhbw-stuttgart’:
from ._anvil_designer import Form1Template
from anvil import *
from _1_GGT import *
class Form1(Form1Template):
def __init__(self, **properties):
self.init_components(**properties)
def link_1_click(self, **event_args):
new_panel = GUI
get_open_form().content_panel.clear()
get_open_form().content_panel.add_component(new_panel)
When running the app, it depicts the menu with item ‘GUI’. But clicking on link ‘GUI’, the app throws a name error:
’ NameError: name ‘GUI’ is not defined at [Form1, line 30](javascript:void(0))’
Obviously, something is wrong with line 30: ‘new_panel = GUI’
Is somebody out there who can give me a hint for this problem?
Thank you in advance for your help!
What does the auto complete say when you start typing from _1 etc…? In my apps that have external dependencies, the auto complete verifies that the dependency can be “seen”. If nothing is coming up in the auto complete, I’d imagine that the issue is that the dependency is not set up correctly.
ImportError: No module named anvil.tables
at app/_1_GGT/GUI/__init__.py, line 3 called from [Form1, line 13](javascript:void(0))
that looks strange in my opinion. I import anvil.tables from ‘1_GGT’, but didn’t import this explicitly with my import starement from ‘dhbw-stuttgart’.
In any case, it seems that the dependency isn’t implemented correctly as I don’t get an autocomplete with typing “from _1_GGT.” as Allan mentioned correctly. This is somehow strange as I explicitly set the dependency within my source app ‘dhbw-stuttgart’. Neither version ‘public’ nor ‘development’ works.
I even set a reciprocal dependency within app ‘GGT’ to ‘dhbw-stuttgart’. Works neiter for me. I’m now somehow walking in a thick mire
My guess is that your current app doesn’t use the anvil.tables service but your dependency does.
Dependencies don’t use their own services they use the services of the live app. So you’ll need to add a datatables service to the live app. Or remove references to the datatables service from the dependency.
Worth noting that your dependency and live app can point to the same table in the datatables service which might help depending on your setup.
Side note. Please use ` back ticks for code not quotes (I’ve edited your posts so the code blocks display correctly)
edit - autocomplete for dependency imports is not currently available I’ll add it to our list