有没有办法使用IPython隐藏显示的对象?
我正在Jupyter笔记本中使用IPython模块。 我正在使用显示模块显示按钮有没有办法使用IPython隐藏显示的对象?,python,python-3.x,ipython,display,Python,Python 3.x,Ipython,Display,我正在Jupyter笔记本中使用IPython模块。 我正在使用显示模块显示按钮 from ipywidgets import widgets import IPython.display as dsply def click_reset(b): print("reset domains button") restoreDomains() resetButton = widgets.Button(description="Reset Domains") resetButton.
from ipywidgets import widgets
import IPython.display as dsply
def click_reset(b):
print("reset domains button")
restoreDomains()
resetButton = widgets.Button(description="Reset Domains")
resetButton.on_click(click_reset)
dsply.display(resetButton)
这很好,但我正在试图找到一种方法,以编程方式隐藏某些按钮。基于其他代码的执行,我希望从UI中删除某些按钮。我可以使用
hide(resetButton)
之类的东西吗?通过将每个小部件的属性visible
设置为False
resetButton.visible = False
当我使用@SergeyGornostaev的答案时,我仍然在单元格输出的左侧显示一个剩余的十字。我发现以下命令会一起删除小部件:
resetButton.close()
你可以使用
让小部件仍占用空间,或
resetButton.layout.display = 'none'
让小部件不再占用空间
不再支持顶级属性resetButton.visible=False
resetButton.layout.display = 'none'