Is there a way in Streamlit to:
Streamlight中是否有方法:
So this would take only the text excerpt selected by the user and send that as a function input and not the entire text in the text area.
因此,这将只获取用户选择的文本摘录,并将其作为函数输入发送,而不是文本区域中的整个文本。
Researched and haven't found a way to do this. Thanks.
已进行了研究,但尚未找到实现此目的的方法。谢谢
更多回答
优秀答案推荐
Here is a simple example with a callback associated to a button, on which you give a text input by a user as argument:
下面是一个简单的例子,其中回调与一个按钮关联,在该按钮上,您可以将用户输入的文本作为参数:
import streamlit as st
st.session_state["user_input"] = st.text_input(label="enter text")
def my_callback(text_to_display):
st.text(str(text_to_display))
st.button("display text", on_click=my_callback, args=(st.session_state["user_input"],))
It gives that when running:
它在运行时给出:
I used these text input doc and button doc.
我使用了这些文本输入文档和按钮文档。
更多回答
Thanks, I meant something a little different. Edited and added an image to make it clearer above.
谢谢,我的意思有点不同。编辑并添加了一个图像,使其在上面更清晰。
我是一名优秀的程序员,十分优秀!