Error while importing a form

What I’m trying to do:

Import my home page inside my login page so that after successful login I have to enable certain components in the Home Page

I am cross referencing Home Page in Login Page and vice versa , is it not allowed ?

What I’ve tried and what’s not working:

this is the error i get

AttributeError: module ‘xpense_tracker_v1.HomePage’ has no attribute ‘HomePage’ at [NewUserReg, line 13](javascript:void(0)) called from [HomePage, line 10](javascript:void(0))

Code Sample:

from ..NewUserReg import NewUserReg  #this is the import from my home page
from ..HomePage import HomePage #this is the import from my Login Page

Clone link:
share a copy of your app

I was able to simulate the same and its due to circular reference , is this a bug and is there a work around , Iam uable to proceed further

The circular reference issue is a Python issue, and solving it means moving one of the imports into a smaller scope.

For example, move your from ..HomePage import HomePage import to just before the line that actually uses HomePage in that module. e.g.:

def form_show(self, **event_args):
    from ..HomePage import HomePage
    form = HomePage()
1 Like

I get it Jay…thx… I moved the import inside my button click event now it does not give any error but iam unable to set a value in of a component inside the home page for example

def btn_save_click(self, **event_args):
    from ..HomePage import HomePage    
    HomePage().label_2.text=self.txt_usrname.text
    HomePage().label_3.text=date.today().strftime('%d-%b-%Y')

Note : the form is containerized inside an alert like this

new_usr=NewUserReg()
choice = alert(new_usr,title="Log In",dismissible=True,buttons=[])

So, when the login is a success I want to enable certain buttons and display the logged in user in the home screen before closing the login screen

Dont bother…i used get_open_form() to set the text to solve this , but Iam curious as to why iam unable to inherit the form :frowning:

When you use code like that you’re creating a new instance of the form, so you’re not changing the label text on the original instance. Using get_open_form () gets you the original instance, which is why that works.

2 Likes