What I’m trying to do:
Hi guys. I’m having difficulty importing forms from within a package. I placed all of my app pages, such as the login form, navbar form etc within the package named ‘App’. See screenshot below:
If the user signs in successfully, I then open the NavBarForm. The code for the loginform which calls the navbar form is shown below:
This used to work fine when all of my forms were at the upper level of my client code. Now that I have moved everything into the ‘App’ package, it no longer works. The autocomplete for the imports still works and gives the current imports as the suggestions. However, as you can see, I’m getting the ModuleNotFoundError.
What am I doing wrong?
Code Sample:
from ._anvil_designer import LoginFormTemplate
from anvil import *
import anvil.server
import anvil.users
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
from ..NavBarForm import NavBarForm
class LoginForm(LoginFormTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
def login_btn_click(self, **event_args):
"""This method is called when the button is clicked"""
user = anvil.users.login_with_form(allow_cancel=True)
if user:
anvil.server.call_s('update_user_login_count')
Notification('Successfully signed in.').show()
open_form('NavBarForm')