Hello everyone. I am very new to Python and Anvil as I come from a js background. Therefore, my problems are due to a lack of my own knowledge rather than anything else. I must say that Python and Anvil are a bit of a revelation to me to be honest - I am loving it so far.
Anyway, to my issue. I have set up a structure as follows:
-
I have a form called “base” that has my top and side nav on it. Within “base” I have a content-panel.
-
I have several other forms that are essentially just columns/cards ready for placement into the “base” content-panel.
-
I replace the “base” content-panel with whichever form/page I need (this is how I produce a multipage website) using things like:
def lk_dashboard_click(self, **event_args):
self.content_panel.clear()
self.content_panel.add_component(dashboard())
-
One of my forms is a repeating panel that for each instance populates a button with a serial number that is pulled from data I have from a json. This serial number is read from the button and placed in a global variable so that I can get at it later, from anywhere.
-
The repeating panel lives in a simple form (for placement into the “base” content-panel). This form is called “show_all”. Therefore, the structure is that show_all is the parent and ItemTemplate1 is the child of show_all, just as it makes it when you drag the repeating_panel component into the page.
My problem:
What I want to do once the button is clicked is clear the whole panel and replace it with the form “show_user”, which is also a simple column/card that sits inside the content-panel. The problem I am having is that I cannot figure out how to do this because my “self” is the repeating panel and I do not understand the parenting. In essence I need to be accessing “base” from here because that is where the content-panel lives, and then clear and replace the current content-panel’s contents (which right now is show_all + ItemTemplate1) with show_user. Effectively at this stage of button click I am completely finished with show_all/ItemTemplate1 and wish to discard/clear it and display show_user in the content_panel of “base”.
ChatGPT has sent me around in circles for a day trying parent.parent.parent, and all manner of other things, but I think it is my understanding that is flawed, and ChatGPT doesn’t really have enough info about Anvil to make sensible suggestions.
I tried things like:
open_form(base)
self.content_panel.clear()
self.content_panel.add_component(show_user())
… but that doesn’t work because I believe it still thinks it’s on the repeating_panel form at this stage.
What I’m trying to do is all very straightforward. (I am not using layouts because in all honesty I did not know about them at the time
The issues are mine, and in me being very new to this. Back in js I would just hit the dom directly, but because of my green status I’m not sure if I my lack of understanding is with Anvil or Python.
I hope someone can shed some light for me.
Thank you.