Add a demo for codemirror #160
Replies: 7 comments 9 replies
-
You can enable codemirror in Here is a demo for Also note that there are some bug when enable codemirror in current pywebio stable version(v1.3.3), you might need to install the dev version. |
Beta Was this translation helpful? Give feedback.
-
Hi that is great! Where is the source to the first demo |
Beta Was this translation helpful? Give feedback.
-
Would you mind elaborating a bit more on what you mean by "how to handle imports"? Couple of things you may be interested:
|
Beta Was this translation helpful? Give feedback.
-
Okay I played with this a little more and now I can articulate what I was looking for a little better. I would like to actually evaluate the code and print the result on the page. What it looks like I am seeing is that I can only input strings and it prints what I input -- no evaluation. In the image below I was expecting a result of |
Beta Was this translation helpful? Give feedback.
-
I see what you are saying about sending code to from pywebio import start_server
from pywebio.output import put_code, put_text
from pywebio.pin import textarea
from pywebio.session import set_env, download
def main():
"""Eval Code"""
set_env(output_animation=False)
res = textarea('Text area', code={
'mode': "python",
'theme': 'darcula'
})
#put_code(res, language='python')
put_text(eval(res))
if __name__ == '__main__':
start_server(main, port=8080, debug=True, cdn=False) |
Beta Was this translation helpful? Give feedback.
-
Another question I have is that import numpy as np
np.array([1,2,3,4,5]) |
Beta Was this translation helpful? Give feedback.
-
Thanks for this! |
Beta Was this translation helpful? Give feedback.
-
I am interested in the codemirror functionality. I would like to see a simple example of code input and a text area of the results.
I have further questions about how to handle imports and how to preinstall packages for a code demo in codemirror, but that would not have to be included in the simple example.
Beta Was this translation helpful? Give feedback.
All reactions