Can I change the content of my page on the fly with Taipy?

94 Views Asked by At

I need to make some modifications to my dashboard and I wanted to know whether it's possible to make those changes on the fly?

1

There are 1 best solutions below

0
Marine On BEST ANSWER

You have the option in Taipy to use partials. They are small blocks of content that can be modified/reloaded dynamically.

Here is an example:

from taipy.gui import Gui 

title = 1

md = """
<|{title}|number|on_change=change_partial|>

<|part|partial={p}|>
"""

def change_partial(state):
    title_int = int(state.title)
    new_html = f'<h{title_int}>test{title_int}</h{title_int}>'
    print(new_html)
    state.p.update_content(state, new_html)

gui = Gui(md)
p = gui.add_partial("<h1>test</h1>")
gui.run()