- class jupyter_rfb.RemoteFrameBuffer(**kwargs)¶
A widget implementing a remote frame buffer.
This widget has the following traits:
css_width: the logical width of the frame as a CSS string. Default ‘500px’.
css_height: the logical height of the frame as a CSS string. Default ‘300px’.
resizable: whether the frame can be manually resized. Default True.
quality: the quality of the JPEG encoding during interaction/animation as a number between 1 and 100. Default 80. Set to lower numbers for more performance on slow connections. Note that each interaction is ended with a lossless image (PNG). If set to 100 or if JPEG encoding isn’t possible (missing pillow or simplejpeg dependencies), then lossless PNGs will always be sent.
max_buffered_frames: the number of frames that is allowed to be “in-flight”, i.e. sent, but not yet confirmed by the client. Default 2. Higher values may result in a higher FPS at the cost of introducing lag.
- print(*args, **kwargs)¶
Print to the widget’s output area (for debugging purposes).
In Jupyter, print calls that occur in a callback or an asyncio task may (depending on your version of the notebook/lab) not be shown. Inside
.handle_event()you can use this method instead. The signature of this method is fully compatible with the builtin print function (except for the
- close(*args, **kwargs)¶
Close all views of the widget and emit a close event.
- snapshot(pixel_ratio=None, _initial=False)¶
Create a snapshot of the current state of the widget.
IPython DisplayObjectthat can simply be used as a cell output. The display object has a
dataattribute that holds the image array data (typically a numpy array).
pixel_ratiocan optionally be set to influence the resolution. By default the widgets’ “native” pixel-ratio is used.
Schedule a new draw. This method itself returns immediately.
This method is automatically called on each resize event. During a draw, the
.get_frame()method is called, and the resulting array is sent to the client. See the docs for details about scheduling.
Restart measuring statistics from the next sent frame.
Get the current stats since the last time
Stats is a dict with the following fields:
sent_frames: the number of frames sent.
confirmed_frames: number of frames confirmed by the client.
roundtrip: avererage time for processing a frame, including receiver confirmation.
delivery: average time for processing a frame until it’s received by the client. This measure assumes that the clock of the server and client are precisely synced.
img_encoding: the average time spent on encoding the array into an image.
b64_encoding: the average time spent on base64 encoding the data.
fps: the average FPS, measured from the first frame sent since
.reset_stats()was called, until the last confirmed frame.
Return image array for the next frame.
Subclasses should overload this method. It is automatically called during a draw. The returned numpy array must be NxM (grayscale), NxMx3 (RGB) or NxMx4 (RGBA). May also return
Noneto cancel the draw.