🔍 What went wrong?
When using async callback in a submodule/page, the state cannot access its state variables.
# main.py
from pages import home
from taipy.gui import Gui, State
def on_change(state: State, var_name: str, var_value):
print(var_name, type(var_value), var_value)
pages = {"/": "", "home": home.home_page}
if __name__ == "__main__":
gui = Gui(pages=pages)
gui.run(run_browser=False)
# pages/home.py
import time
import taipy.gui.builder as tgb
from taipy.gui import State
counter = 0
async def count_to_10(state: State):
for i in range(10):
state.counter = i + 1
time.sleep(1)
with tgb.Page() as home_page:
tgb.button("Count to 10", on_action=count_to_10)
tgb.text("{counter}")
Click button, then console:
/home/testbench/.venv-git-2026-02-24/lib/python3.12/site-packages/taipy/gui/gui.py:2340: TaipyGuiWarning: Variable 'counter' is not available in the '__main__' module.
_warn(
📦 Taipy Version
develop
📋 Additional Context (Optional)
📜 Code of Conduct
✅ Acceptance Criteria
🔍 What went wrong?
When using async callback in a submodule/page, the state cannot access its state variables.
Click button, then console:
📦 Taipy Version
develop
📋 Additional Context (Optional)
📜 Code of Conduct
✅ Acceptance Criteria