Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在ipywidgets文本区域的插入符号处插入文本_Python_Ipython_Jupyter_Ipywidgets - Fatal编程技术网

Python 如何在ipywidgets文本区域的插入符号处插入文本

Python 如何在ipywidgets文本区域的插入符号处插入文本,python,ipython,jupyter,ipywidgets,Python,Ipython,Jupyter,Ipywidgets,我正在jupyter笔记本中使用ipywidgets,并试图将文本插入文本框。我有代码将适当的文本追加到末尾,但我希望它插入到当前文本光标处。以下是a公司目前拥有的模型: from ipywidgets import Button,Text a = Text(description='text', disabled=False) b = Button(description='Awesome', disabled=False) def on_button_cl

我正在jupyter笔记本中使用ipywidgets,并试图将文本插入文本框。我有代码将适当的文本追加到末尾,但我希望它插入到当前文本光标处。以下是a公司目前拥有的模型:

from ipywidgets import Button,Text

a = Text(description='text',
         disabled=False)
b = Button(description='Awesome',
       disabled=False)

def on_button_clicked(b):
    a.value+=b.description

b.on_click(on_button_clicked)

display(a,b)
当我试着用谷歌搜索我的问题时,我发现了很多用javascript或tk实现这一点的例子,但我似乎不知道如何用IPyWidget实现这一点


如何获取ipywidgets文本框的插入符号位置?

我认为ipywidgets中没有内置的方法,您在其他地方发现的JS方法可能是最好的方法,我担心没有直接使用ipywidgets的方法。我不确定如何在python笔记本中实现JS方法,但这似乎是谷歌下一步要做的事情。