如何通过交互式小部件(python)在Jupyter笔记本中定义变量名

如何通过交互式小部件(python)在Jupyter笔记本中定义变量名,python,jupyter-notebook,Python,Jupyter Notebook,我需要以下功能: #what do you want to name the processed file? (widget here) filename=(widget input string) 我在小部件文档或其他搜索中没有找到任何简单的示例 您可以使用标准python输入 或者使用ipywidgets模块 另请参阅ipywidgets模块的文档 text = input("Your input: ") print(text) import ipywidgets as widgets

我需要以下功能:

#what do you want to name the processed file?
(widget here)

filename=(widget input string)

我在小部件文档或其他搜索中没有找到任何简单的示例

您可以使用标准python输入

或者使用ipywidgets模块

另请参阅ipywidgets模块的文档

text = input("Your input: ")
print(text)
import ipywidgets as widgets
text = widgets.Text(placeholder='Your input')
display(text)

def print_input(sender):
    print(text.value)

text.on_submit(print_input)