taipy
taipy copied to clipboard
Add markdown to page builder
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()
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()
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()
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()
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.
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()