Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to hide a displayed object using IPython?

I am using the IPython module in a Jupyter Notebook. I am using the display module to display buttons.

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)

This works fine, but I am trying to find a way to programatically hide certain buttons. Based off the execution of my other code, I want certain buttons to be removed from the UI. Is there anything like hide(resetButton) that I can use?

like image 757
GreySage Avatar asked Dec 06 '22 17:12

GreySage


1 Answers

You can hide a widget using

resetButton.layout.visibility = 'hidden'

to let the widget still consume space, or

resetButton.layout.display = 'none'

to let the widget not consume space anymore.

The top-level attribute resetButton.visible = False is not longer supported.

like image 136
Jan Martin Keil Avatar answered Dec 15 '22 18:12

Jan Martin Keil