Search code examples
pythontaipy

How do I properly display variables in Markdown headers with Taipy GUI


I built a dashboard application using the Taipy GUI python library.

The app has a variable called "country", and its value can be assigned using a drop-down selector, with the following syntax:

<|{country}|selector|lov={lov_region}|on_change=on_change_country|dropdown|label=Country/Region|>

The selector works fine and it properly assigns the values of a country to the <|country|> variable when selected.

When I try to use the value of the <|country|> variable to create a Markdown title, I use the following code (in this case, for a <h2> header):

## Fossil fuel per capita for <|{country}|>:

It works But the problem is how the value for the <|country|> variable is displayed. It looks different than the rest of the header.

For example, in the image below, where <|country|> is set to "Philippines":

enter image description here


Solution

  • You can add the property raw to your visual element.

    ## Fossil fuel per capita for <|{country}|text|raw|>:
    

    The text will take the appropriate format automatically.