简体   繁体   English

如何在Jupyter Notebook中通过交互式小部件(Python)定义变量名

[英]How to define variable name in Jupyter notebook through interactive widget (python)

I need the following functionality: 我需要以下功能:

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

filename=(widget input string)

I did not find any easy examples in the widget documentation or other searches. 我没有在小部件文档或其他搜索中找到任何简单的示例。

You can either use standard python input() 您可以使用标准的python input()

text = input("Your input: ")
print(text)

or use the ipywidgets module 或使用ipywidgets模块

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

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

text.on_submit(print_input)

also see the docs for the ipywidgets module here . 也可以在这里查看ipywidgets模块的文档。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jupyter notebook 中的交互式 python matplolib 小部件未按预期更新 - Interactive python matplolib widget doesn't update as expected in jupyter notebook 如何在 Jupyter Notebook 和 Python 中创建交互式绘图 - How to create interactive plot in Jupyter Notebook and Python 在交互式小部件中而不是在jupyter笔记本中打开pandas数据框 - Open a pandas dataframe in an interactive widget, NOT in a jupyter notebook 通过选择小部件在Jupyter Notebook上进行交互式选择会引发“模型必须仅由单个文档拥有”错误 - Interactive Selection on Jupyter Notebook through Select Widget raise “Models must be owned by only a single document” error python 如何在交互式解释器和 jupyter notebook 中实习字符串 - How python interns strings in interactive interpreter vs jupyter notebook Jupyter Notebook:如何在 function 之外使用 ipython 小部件变量 - Jupyter Notebook: how to use ipython widget variable outside the function python 交互式/jupyter 笔记本中的 psycopg2 OperationalError - psycopg2 OperationalError in python interactive/jupyter notebook 如何在Jupyter Notebook中显示小部件? - How to display widget in Jupyter Notebook? Jupyter Notebook中的交互式多图表小部件,用于熊猫数据框 - Interactive multi chart widget in jupyter notebook for pandas dataframe 如何在打印语句或任何文本 output 语句中打印变量名称。 Python,Jupyter 笔记本? - How to print a variable name in a print statement or any text output statement. Python, Jupyter Notebook?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM