@@ -38,7 +38,7 @@ def envset(name, default):
38
38
JUPYTER_WIDGETS_ECHO = envset ('JUPYTER_WIDGETS_ECHO' , default = True )
39
39
# we keep a strong reference for every widget created, for a discussion on using weak references see:
40
40
# https://github.com/jupyter-widgets/ipywidgets/issues/1345
41
- instances : typing .MutableMapping [str , "Widget" ] = {}
41
+ _instances : typing .MutableMapping [str , "Widget" ] = {}
42
42
43
43
def _widget_to_json (x , obj ):
44
44
if isinstance (x , dict ):
@@ -55,8 +55,8 @@ def _json_to_widget(x, obj):
55
55
return {k : _json_to_widget (v , obj ) for k , v in x .items ()}
56
56
elif isinstance (x , (list , tuple )):
57
57
return [_json_to_widget (v , obj ) for v in x ]
58
- elif isinstance (x , str ) and x .startswith ('IPY_MODEL_' ) and x [10 :] in instances :
59
- return instances [x [10 :]]
58
+ elif isinstance (x , str ) and x .startswith ('IPY_MODEL_' ) and x [10 :] in _instances :
59
+ return _instances [x [10 :]]
60
60
else :
61
61
return x
62
62
@@ -302,13 +302,13 @@ class Widget(LoggingHasTraits):
302
302
303
303
@_staticproperty
304
304
def widgets ():
305
- warnings .warn ("Widget.widgets is deprecated, use ipywidgets.widgets.widget.instances " , DeprecationWarning )
306
- return instances
305
+ warnings .warn ("Widget.widgets is deprecated, use ipywidgets.widgets.widget._instances " , DeprecationWarning )
306
+ return _instances
307
307
308
308
@_staticproperty
309
309
def _active_widgets ():
310
- warnings .warn ("Widget._active_widgets is deprecated, use ipywidgets.widgets.widget.instances " , DeprecationWarning )
311
- return instances
310
+ warnings .warn ("Widget._active_widgets is deprecated, use ipywidgets.widgets.widget._instances " , DeprecationWarning )
311
+ return _instances
312
312
313
313
@_staticproperty
314
314
def _widget_types ():
@@ -322,7 +322,7 @@ def widget_types():
322
322
323
323
@classmethod
324
324
def close_all (cls ):
325
- for widget in list (instances .values ()):
325
+ for widget in list (_instances .values ()):
326
326
widget .close ()
327
327
328
328
@staticmethod
@@ -364,7 +364,7 @@ def _handle_control_comm_msg(cls, msg):
364
364
if method == 'request_states' :
365
365
# Send back the full widgets state
366
366
cls .get_manager_state ()
367
- widgets = instances .values ()
367
+ widgets = _instances .values ()
368
368
full_state = {}
369
369
drop_defaults = False
370
370
for widget in widgets :
@@ -415,7 +415,7 @@ def get_manager_state(drop_defaults=False, widgets=None):
415
415
"""
416
416
state = {}
417
417
if widgets is None :
418
- widgets = instances .values ()
418
+ widgets = _instances .values ()
419
419
for widget in widgets :
420
420
state [widget .model_id ] = widget ._get_embed_state (drop_defaults = drop_defaults )
421
421
return {'version_major' : 2 , 'version_minor' : 0 , 'state' : state }
@@ -511,7 +511,7 @@ def _comm_changed(self, change):
511
511
self ._model_id = self .model_id
512
512
513
513
self .comm .on_msg (self ._handle_msg )
514
- instances [self .model_id ] = self
514
+ _instances [self .model_id ] = self
515
515
516
516
@property
517
517
def model_id (self ):
@@ -531,7 +531,7 @@ def close(self):
531
531
When the comm is closed, all of the widget views are automatically
532
532
removed from the front-end."""
533
533
if self .comm is not None :
534
- instances .pop (self .model_id , None )
534
+ _instances .pop (self .model_id , None )
535
535
self .comm .close ()
536
536
self .comm = None
537
537
self ._repr_mimebundle_ = None
0 commit comments