Replacing output.put_markdown() with each step #179
Answered
by
helincao
quadratecode
asked this question in
Q&A
-
I am envisioning a web app where with each input another block of markdown should replace the previous one. Like so: from pywebio import *
def main():
output.put_markdown("""# This is the title #
## This is the subtitle ##
This is the description""", lstrip=True) # MD block 1
name = input.input("Your name")
output.put_markdown("""# Terms and Conditions
This is a paragraph exlaining the terms and conditions""", lstrip=True) # MD block 2 (should replace MD block 1)
conditions = input.checkbox("Terms and Conditions", options=["I accept the terms and conditions"])
output.put_markdown(name) # MD block 3 (should replace MD block 2)
if __name__ == '__main__':
start_server(main, port=8080, debug=True) Is there a way to accomplish this? Right now, all the MD-blocks remain if the next one is displayed. Any help is much appreciated! Edit - updated code to reflect the comment by @helincao for anyone coming accross this: from pywebio import *
def main():
with output.use_scope("scope1"):
output.put_markdown("""# This is the title #
## This is the subtitle ##
This is the description""", lstrip=True) # MD block 1
name = input.input("Your name")
with output.use_scope("scope1", clear=True):
output.put_markdown("""# Terms and Conditions
This is a paragraph exlaining the terms and conditions""", lstrip=True) # MD block 2 (should replace MD block 1)
conditions = input.checkbox("Terms and Conditions", options=["I accept the terms and conditions"])
with output.use_scope("scope1", clear=True):
output.put_markdown(name) # MD block 3 (should replace MD block 2)
if __name__ == '__main__':
start_server(main, port=42502, debug=True) |
Beta Was this translation helpful? Give feedback.
Answered by
helincao
Oct 27, 2021
Replies: 1 comment 1 reply
-
You can put MD content in |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
quadratecode
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can put MD content in
scope
, and setclear=True
to make previous output disappear.Doc: https://pywebio.readthedocs.io/en/latest/guide.html?highlight=scope#output-scope