displaydev.jndisplay
displaydev.jndisplay
- class displaydev.jndisplay.JNDevices(display_drv)[source]
Bases:
objectUnified input for Jupyter Notebook, registered as an appdev HOST device.
Creates the interactive
ipywidgetsImage that mirrors the display buffer and watches it (viaipyevents) for all available input, turning it intoeventsobjects (matching the desktop SDL2 / PyGame event stream), drained throughread:Mouse:
MOUSEMOTIONon every move,MOUSEBUTTONDOWN/MOUSEBUTTONUPfor any button.Wheel:
MOUSEWHEEL(also consumed by encoder devices).Keyboard:
KEYDOWN/KEYUPwith SDL-style key codes, names and modifier masks (left/right modifier variants via key location).
Quit chord handling is configured on
JNDisplayviaquit_chord(default(keys.K_AC_BACK, 0)).HostEventsapplies the chord when constructed withdisplay=.This class also owns the display widget:
JNDisplaypushes frames to it viaupdate_buffer.Note
The Image widget must be focused (e.g. clicked) to receive key events, and some keys may be consumed by the notebook front end (JupyterLab / classic Notebook / VS Code) before they reach the widget.
- Parameters:
display_drv (JNDisplay) – Display whose buffer is shown on the Image widget.
- class displaydev.jndisplay.JNDisplay(width, height, *, quiet=False)[source]
Bases:
DesktopDisplayEmulate a display in a Jupyter Notebook output cell.
Supports ILI9341-style vertical scroll emulation (same band compositing as SDL/PG/PS). Interactive output uses
JNDevices; static notebooks can callshowwithout a device.- Parameters:
- quit_chord
Keyboard chord for quit (default browser Back);
Nonedisables.
- get_events()[source]
Drain Jupyter input; lazily create
JNDeviceson first use.Static notebooks that only call
shownever touch this and keep the non-interactive path.
- fill_rect(x, y, w, h, c)[source]
Fills a rectangle with the given color.
- Parameters:
- Returns:
(tuple) – A tuple containing the x, y, w, h values
- blit_rect(buf, x, y, w, h)[source]
Blits a buffer to the display at the given coordinates.
- Parameters:
- Returns:
(tuple) – A tuple containing the x, y, w, h values.