In Taipy, I need to show the Dashboard based on the selection in the dropdown.

For instance, I have two Environment-['DEV','PROD'],Start_Date and End_Date. These three will be showed in the dropdown of UI. - When the User select DEV, it should connect with DEV server and extract the data and create a Dashboard . - When PROD is selected, it should connect with PROD server and extract the data and overwrite the previous Dashboard and show the PROD dashboard.

So, how to use the IF statement in the "gui=GUI(pages=pages).run()"

Able to extract only one server data and process with it. Not sure, how to extract and handle based on the selection.

1

There are 1 best solutions below

0
Florian Jacta On

You are looking to change the content of your page in runtime. For this purpose, the partial concept exists. A partial can be changed in run time.

Here is a related question on Stackoverflow.

Partials

You have the option in Taipy to use partials. They are blocks of content that can be modified/reloaded dynamically. For the moment, they use the Markdown syntax to be updated:

import taipy.gui.builder as tgb
from taipy import Gui


input_name = "Taipy"
message = None


with tgb.Page() as page:
    tgb.input("{input_name}")
    tgb.text("{message}")
    tgb.button("add" , on_action='add_element')
    tgb.part(partial='{dynamic_content}')


def add_element(state):
    state.dynamic_content.update_content(state, '<|input|>')


gui = Gui(page)
dynamic_content = gui.add_partial('')
gui.run()

However, in 3.0.0, you can only update your partial with the Markdown syntax. I don't know if you use the Python API or the Markdown

If you know how to install the develop version of Taipy, you can also use the Taipy Gui Builder to change a partial in runtime.

from taipy.gui import Gui 
import taipy.gui.builder as tgb
from math import cos, exp

value = 10

def change_partial(state):
    with tgb.Page() as partial:
        for i in range(state.value):
            tgb.text(value="Card")
    state.partial.update_content(state, partial)

with tgb.Page() as partial_page:
    tgb.text(value="Initial partial")
    
with tgb.Page() as page:
    tgb.slider(value="{value}")
    tgb.button("Change partial", on_action=change_partial)
    tgb.part(partial="{partial}") 


gui = Gui(page=page)
partial = gui.add_partial(partial_page)
gui.run(title="Frontend Demo")

To install the develop branch, you should have NodeJS installed on your laptop and git installed (conda install git for example). Then, pip install git+https://github.com/Avaiga/taipy.git and this should install the develop version of Taipy. I can assist you in this process if you'd like