taipy icon indicating copy to clipboard operation
taipy copied to clipboard

Add markdown to page builder

Open Forchapeatl opened this issue 1 year ago • 3 comments

I need to add markdown to taipy page builder , please how can i do this?

with tgb.Page() as page:
    for i in range(4):
        tgb.text(f'My text: {i}')

page.append("""<|submit|button|>""")

Gui(page).run()

Forchapeatl avatar Nov 02 '23 11:11 Forchapeatl

All controls can be now written with this new Python API. Check the documentation here.

with tgb.Page() as page:
    for i in range(4):
        tgb.text(f'My text: {i}')

    tgb.button("submit")

Gui(page).run()

FlorianJacta avatar Nov 02 '23 12:11 FlorianJacta

Thank you for the information @FlorianJacta , The problem is , the markdown accepts Global variables while the page builder can accept local variables.

take these two samples for example: Sample 1

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

# Python API
page = """"""


for i in range(4):
    page += '<|{i}|text|>'

# Markdown API
md = "Markdown page"

# Definition of th pages
pages = {"/": "<|navbar|>",
         'python': page,
         'markdown': md}


Gui(pages=pages).run()

image

Sample2

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

# Python API
with tgb.Page() as page:
    for i in range(4):
        tgb.text(f'{i}')

# Markdown API
md = "Markdown page"

# Definition of th pages
pages = {"/": "<|navbar|>",
         'python': page,
         'markdown': md}


Gui(pages=pages).run()

image

Sample1 sees { i }as a global variable while Sample2 sees { i } as a local variable. Thats why I need page builder in combination with the markdown.

Forchapeatl avatar Nov 02 '23 14:11 Forchapeatl

In the Markdown example, you won't be able to change the value of each i independently. It is just displaying one variable.

To bind different variables with the Python API, you can put your variables in a dictionary.

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

dict_i = {}

# Python API
with tgb.Page() as page:
    for i in range(4):
        dict_i['id_'+str(i)] = i
        tgb.text('{dict_i.id_'+str(i)+'}')
        tgb.slider('{dict_i.id_'+str(i)+'}')

# Markdown API
md = "Markdown page"

# Definition of th pages
pages = {"/": "<|navbar|>",
         'python': page,
         'markdown': md}


Gui(pages=pages).run()

FlorianJacta avatar Nov 06 '23 11:11 FlorianJacta