popup-code directive#
Open an interactive-code Python editor in a draggable, resizable window.
Students can keep reading the page while the window is open, close it with
the close button or Escape, and reopen it without losing code or output.
Drag the title bar to move the window (mouse, touch, or pen).
Basic usage#
```{popup-code}
for i in range(3):
print(i)
```
An empty body opens a blank editor. Run, reset, cancel, and Python output
work just as in interactive-code.
Options#
Option |
Meaning |
Default |
|---|---|---|
|
Initial window width in pixels |
|
|
Initial window height in pixels |
|
|
Launcher label |
|
|
Window title |
|
|
|
|
|
Unique, stable editor name within this page |
Generated |
|
Language; currently only |
|
|
Ask students to predict output first, as in |
Off |
Options override positional arguments. Use distinct name values on the
same page to preserve saved code across rebuilds. The existing editor saves
code in the browser’s local storage; output and window placement are retained
only while the page remains loaded.
The directive is registered by munchboka_edutools. It can also be enabled
individually as munchboka_edutools.directives.popup_code.