Currently to reset the page variables and elements I use,
def refresh_project_part(state):
state.name = None
state.description = None
state.p_name = None
state.p_description = None
state.cad_filepath= None
But this hinders the page response time. and there is a delay every time I navigate between pages. is it possible to refresh the page somehow?
They are no easy way to reinitialize certain elements of a Gui after navigating to a page.
I would suggest creating a dictionary with all the fields of your form and to reinitialize it after saving your form.
Markdown syntax:
from taipy.gui import Gui, notify
form = {"Name":"",
"Email":"",
"Phone":""}
md = """
<|{form.Name}|input|>
<|{form.Email}|input|>
<|{form.Phone}|input|>
<|Submit|button|on_action=save|>
"""
def save(state):
notify(state, "success", "Saved!")
state.form = {key:"" for key in form.keys()}
Gui(md).run()
Page Builder:
from taipy.gui import Gui, notify
import taipy.gui.builder as tgb
form = {"Name":"",
"Email":"",
"Phone":""}
def save(state):
notify(state, "success", "Saved!")
state.form = {key:"" for key in form.keys()}
with tgb.Page() as page:
for key in form:
tgb.input('{form.'+key+'}', label=key)
tgb.button("Submit", on_action=save)
Gui(page).run()
Does that solve your issue?