What I’m trying to do:
Trying to write some functions in the module under a form
What I’ve tried and what’s not working:
- unable to import my top level form inside my module
- Trying to create a function to display a content box from any where
- How do i refer to an element inside my Form1 from a module
Iam uploading my app structure
Code Sample:
import anvil.server
import anvil.google.auth, anvil.google.drive
from anvil.google.drive import app_files
import anvil.users
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
This is a module.
You can define variables and functions here, and use them from any form. For example, in a top-level form:
from .Form1 import Module2
Module2.say_hello()
def say_hello():
print(“Hello, world”)
def display_input_box(plc_hldr,titl,min_chars):
txt_box = get_open_form().TextBox(placeholder=plc_hldr)
alert(content=txt_box,title=titl)
if len(txt_box.text.strip())<min_chars:
alert(f"Enter a valid reason not less than {min_chars} Characters…")
return “ERR”
else:
return “OK”
# code snippet
Clone link:
share a copy of your app