Hello,
I’m relatively new to both python and anvil and I have been struggling trying to reference forms within forms. This is the hierarchy of my navigation:
I have a main form that includes a sub-form for an Overview Page, in this overview page I’ve used anvil extras tab component. Now this Overview form also has two sub-forms each for one of the options of the tabs. I also a navigation module that basically arranges the content as needed.
The issue is that I cant get the tabs_click to work, I think I have a fundamentally wrong understanding on how the click events work: I keep getting a warning:
Warning: overview_tabsTemplate.tab_overview_tab_click does not exist. Trying to set the ‘tab_click’ event handler of self.tab_overview from overview_tabsTemplate.
Although the tab component is responsive and the click looks like its working as a component I cant interface with it in the code.
Code Sample:
This is the code of the Overview Page that has the Tab component:
from ._anvil_designer import overview_tabsTemplate
from anvil import *
import anvil.users
from ... import navigation
class overview_tabs(overview_tabsTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run before the form opens.
def tab_overview_tab_click(self, tab_index, tab_title, **event_args):
if tab_index == 0:
navigation.project_home()
if tab_index == 1:
navigation.project_econ()
And the code for the main page:
from ._anvil_designer import HomeDashboardTemplate
from anvil import *
import plotly.graph_objects as go
import anvil.users
from .. import navigation
from .overview_tabs import overview_tabs
class HomeDashboard(HomeDashboardTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
navigation.home_form = self
navigation.project_home()
# Any code you write here will run before the form opens.
def nav_project_click(self, **event_args):
navigation.project_home()
def nav_ath_click(self, **event_args):
navigation.ath_home()
def nav_lam_click(self, **event_args):
navigation.lam_home()
def load_component(self, cmpt):
self.home_content_panel.clear()
self.home_content_panel.add_component(cmpt)
Any guidance would be greatly appreciated,
Thanks