一个可编辑的文本框,用于实时执行Python代码
项目描述
ExecBox - 在你的Streamlit应用中执行Python代码!
Execbox基本上是一个文本编辑器加上exec()
。
安装
首先安装Streamlit(当然!)然后pip安装这个库
pip install streamlit
pip install st-execbox
示例用法
import streamlit as st
from st_execbox import execbox
# Draw a text editor and a "Run" button. When you press "Run", the code in the editor executes!
execbox()
# Makes the code run automatically on each keystroke.
execbox(autorun=False)
# Draw an execbox with some initial text.
execbox("""
a = 10
b = 20
st.write(a + b)
""")
参数
execbox()
函数接受以下任一参数
-
body (str. 默认: '')
在execbox中显示的初始代码。
-
button_label (str. 默认: '运行')
用于"运行"按钮的标签。
-
autorun (bool. 默认: False)
是否在每次按键时执行代码。
-
height (int 或 None. 默认: None)
execbox的高度,以像素为单位。如果为
None
,则智能计算高度以填充内容和额外几行。 -
line_numbers (bool. 默认: False)
是否显示行号。
-
key (str 或 None. 默认: None)
用作小部件唯一键的可选字符串。如果省略,则根据其内容为小部件生成键。相同类型的小部件可能无法共享相同的键。
待办事项
仅有一个待办事项
- 编写测试!接受贡献 :wink
项目详情
关闭
st-execbox-1.0.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 3510038e82019391d5f0f3ae752f43e2f4768a7c2f56087b82bba94a9fa48e79 |
|
MD5 | 0f15b61ed9d9885b6e59cbf0977d27a7 |
|
BLAKE2b-256 | ca3402c1540badd23c2d453ee280e1f478949ff1873b9ea5acdab5dff184ab93 |