清除和重置 ipywidgets 的 TextArea。

huangapple go评论57阅读模式
英文:

ipywidgets clear and reset TextArea

问题

在我向TextArea添加一些文本并对该文本进行一些预处理后,我希望重置TextArea小部件,以便我可以添加新的文本。

例如:

q1 = Textarea(layout=Layout(width='70%', height='100px'))
q1 # 打开一个窗口,然后我向其中添加文本
q2 = re.sub(r'[^\x00-\x7f]', '', q1.value)
# 进行更多的预处理
q1.reset() # 我希望有类似这样的操作

在预处理完成后,我想将q1重置为空白,以便它准备好接受全新的输入值。

对此的任何帮助都将不胜感激。

英文:

After I add some text to TextArea and run some preprocessing on that text I would like to reset the TextArea widget so I can add new text to it.

For example:

q1 = Textarea(layout=Layout(width='70%', height='100px'))
q1 # opens a window and then I add text to it

清除和重置 ipywidgets 的 TextArea。

q2 = re.sub(r'[^\x00-\x7f]',r'', q1.value)
# do some more preprocessing
q1.reset() # I am looking for something like this

After preprocessing is complete, I'd like to reset q1 to a blank cell so it is ready to take in as input a completely new value.

Any help on this is appreciated.

答案1

得分: 1

你可以为TextArea小部件分配任何值。

所以答案非常简单。

q1.value = ""
   
# 显示文本区现在为空。
    
q1
英文:

You can assign any value to the TextArea widget.

So the answer is really simple.

q1.value = ""

# Show that the text area is now empty.

q1

huangapple
  • 本文由 发表于 2023年7月14日 03:54:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76682815.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定