Embedding in an ipywidgets appΒΆ

In this example we demonstrate embedding the RemoteFrameBuffer class inside a larger ipywidgets app.

[ ]:
import numpy as np
import ipywidgets
import jupyter_rfb

Implement a simple RFB class, for the sake of the example:

[ ]:
class SimpleRFB(jupyter_rfb.RemoteFrameBuffer):

    green_value = 200

    def get_frame(self):
        a = np.zeros((100, 100, 3), np.uint8)
        a[20:-20,20:-20,1] = self.green_value
        return a

Compose a simple app:

[ ]:
slider = ipywidgets.IntSlider(min=50, max=255, value=200)
rfb = SimpleRFB()

def on_slider_change(change):
    rfb.green_value = change["new"]

slider.observe(on_slider_change, names='value')
ipywidgets.HBox([rfb, slider])
[ ]: