Is it normal that when I attempt to add a value to my list or change my data using a button, I do not observe any modifications on the GUI?
Despite this, after refreshing the page, the accurate list is displayed.
from taipy.gui import Gui
import pandas as pd
a_list = [1,2,3]
data = pd.DataFrame({"x":[1,2,3], "y":[2,1,3]})
md = """
<|Update|button|on_action=update|>
# My list
<|{a_list}|>
# My data
<|{data}|table|width=fit-content|>
"""
def update(state):
state.a_list.append(4)
state.data["y"] = [10, 4, 3]
Gui(md).run()
For example, in the code above, clicking the button should add 4 to my list and change my table. However, I see no modification in real time. When I refresh my page, I see the right modifications.
Taipy does not directly change your GUI with this set of specific assignments (.append()
, .drop()
). You must use a regular ‘equals’ assignment to see changes in real time (state.xxx = yyy
). Your code will look like this:
from taipy.gui import Gui
import pandas as pd
a_list = [1,2,3]
data = pd.DataFrame({"x":[1,2,3], "y":[2,1,3]})
md = """
<|Update|button|on_action=update|>
# My list
<|{a_list}|>
# My data
<|{data}|table|width=fit-content|>
"""
def update(state):
state.a_list += [4]
temp = state.data
temp["y"] = [10, 4, 3]
state.data = temp
Gui(md).run()