INNER CODE UNIT · Python
_plot_window_open
briscverse/ryp · ryp.py:1471
def _plot_window_open() -> bool:
"""
Checks whether a plot window is open, by checking whether R's .Devices
variable contains a graphics device with a name that's not the empty string
(which can happen if a plot window was closed) or 'null device' and does
not have the 'filepath' attribute (which non-interactive graphics devices
like png() and pdf() do).
Returns:
Whether the plot window is open.
"""
devices = _rlib.Rf_findVar(_rlib.Rf_install(b'.Devices'), _rlib.R_BaseEnv)
while True:
device_name = \
_ffi.string(_rlib.R_CHAR(_rlib.STRING_ELT(_rlib.CAR(devices), 0)))
if device_name != b'' and device_name != b'null device' and \
_rlib.Rf_getAttrib(_rlib.CAR(devices),
_rlib.Rf_install(b'filepath')) == \