vispy / jupyter_rfb

Remote Frame Buffer for Jupyter
https://jupyter-rfb.readthedocs.io
MIT License
55 stars 10 forks source link

Show / hide windows? #13

Closed almarklein closed 2 years ago

almarklein commented 2 years ago

Normal windows can be closed (i.e. hidden), do we want something similar? Do other widget subclasses support this? Is this a sensible part of the notebook workflow?

almarklein commented 2 years ago

Since a widget can have multiple simultaneous views, it seems to me that this would be too complicated/weird, unless showing and hiding a widget can only be done programmatically (showing/hiding all views), but I suspect that this should not be the responsibility of the RFB widget, since cases like this can be done by the Notebook (clear the cell output), or the RFB subclass (make it stop sending new frames).

Leaving this open for now to give people a chance to react.

djhoese commented 2 years ago

How does matplotlib do this? If I recall correctly you can typically resize mpl widgets in a notebook, but to completely get rid of them you have to clear the cell output. However, there may be some odd behavior if you don't create a new mpl figure and do more drawing commands. Like it might produce duplicate figure output (one for each cell that has drawing commands), but I can't remember if the new cells update the previous cells output (they're all connected, one figure on the backend) or if they are independent (individual figure<->widget pairs).

almarklein commented 2 years ago

Yeah, in the notebook you can toggle the visibility of the output, and also clear an output (which removes the widget view, but does not close the model). This should be plenty.

Relatedly, ipywidets.Widget has a .close() method (and so does the corresponding model in JS), that destroys the widget. With #15 we can thus properly implement canvas.close() in vispy.

Also related, in #12 I propose to detect whether any of the views are actually visible. If none are, we can pause drawing and thus safe CPU cycles for other stuff (e.g. other widgets sending frames).

With that, I close this issue :)