Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.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
有没有办法使用IPython隐藏显示的对象?_Python_Python 3.x_Ipython_Display - Fatal编程技术网

有没有办法使用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.

我正在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.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'