What I’m trying to do:
I am trying to import the ‘parent’ form of this component, so that I can call functions in it. The circumstances:
This is a ‘files’ app so you can save text files. I am trying to add functionality to sort these files into ‘folders’. The Folder template, component form, repeated in a LinearPanel, which is passed the folder name from HomeScrn as a property, has a button on it that when clicked is supposed to change the folder shown on the page for the file app (HomeScrn). But here’s where problems occured:
I couldn’t import the HomeScrn form - AttributeError; ‘HomeScrn has no attribute HomeScrn’ - in the Folder component form, despite following the dropdown suggestions in Code.
Help!
PS If you need further explanation just say. Unfortunately it’s quite hard to clone the app, sorry.
The details are a little unclear to me in terms of being able to give an exact answer. Could you clone a small app that demonstrates the issue (not your actual app)? This would really help.
In general though you could search the forum and docs for:
importing forms
how to call a function from another form
how to pass variables between forms
There should be a lot of helpful info there that will likely be relevant.
In C/C++, you would need to #include the parent form’s definition, in order for the compiler to understand what type it’s dealing with, and make calls to objects of that type.
In Python, you don’t need to do that. Once an object (the parent form) exists, it carries all those details with it, for last-instant lookup. Once you get a reference to that object, that’s sufficient for accessing all of the object’s members, including members that happen to be functions.
Thanks for your help, @alcampopiano, @p.colbert and @stucork - I didn’t previously know you couldn’t circular import, let alone know what that was.
So basically, I just got rid of the need for the circular import, and on the HomeScrn form (see cloned app), just changed the LinearPanel to a RepeatingPanel so there’s no need to import the components.
Fingers crossed, this won’t fail me too! PS you can find my actual published app, currently under development but half done at vsuite3.anvil.app (moving soon to vsuite.anvil.app). It’s an app aiming to be similar to, but much more simple than O365 and G Suite etc.