@@ -112,7 +112,12 @@ class AxesWidget(Widget):
112112 def __init__ (self , ax ):
113113 self .ax = ax
114114 self .canvas = ax .figure .canvas
115- self .cids = []
115+ self ._cids = []
116+
117+ @cbook .deprecated ("3.4" )
118+ @property
119+ def cids (self ):
120+ return self ._cids
116121
117122 def connect_event (self , event , callback ):
118123 """
@@ -122,11 +127,11 @@ def connect_event(self, event, callback):
122127 function stores callback ids for later clean up.
123128 """
124129 cid = self .canvas .mpl_connect (event , callback )
125- self .cids .append (cid )
130+ self ._cids .append (cid )
126131
127132 def disconnect_events (self ):
128133 """Disconnect all events created by this widget."""
129- for c in self .cids :
134+ for c in self ._cids :
130135 self .canvas .mpl_disconnect (c )
131136
132137
@@ -175,8 +180,8 @@ def __init__(self, ax, label, image=None,
175180 horizontalalignment = 'center' ,
176181 transform = ax .transAxes )
177182
178- self .cnt = 0
179- self .observers = {}
183+ self ._cnt = 0
184+ self ._observers = {}
180185
181186 self .connect_event ('button_press_event' , self ._click )
182187 self .connect_event ('button_release_event' , self ._release )
@@ -188,6 +193,16 @@ def __init__(self, ax, label, image=None,
188193 self .color = color
189194 self .hovercolor = hovercolor
190195
196+ @cbook .deprecated ("3.4" )
197+ @property
198+ def cnt (self ):
199+ return self ._cnt
200+
201+ @cbook .deprecated ("3.4" )
202+ @property
203+ def observers (self ):
204+ return self ._observers
205+
191206 def _click (self , event ):
192207 if (self .ignore (event )
193208 or event .inaxes != self .ax
@@ -204,7 +219,7 @@ def _release(self, event):
204219 if (not self .eventson
205220 or event .inaxes != self .ax ):
206221 return
207- for cid , func in self .observers .items ():
222+ for cid , func in self ._observers .items ():
208223 func (event )
209224
210225 def _motion (self , event ):
@@ -222,15 +237,15 @@ def on_clicked(self, func):
222237
223238 Returns a connection id, which can be used to disconnect the callback.
224239 """
225- cid = self .cnt
226- self .observers [cid ] = func
227- self .cnt += 1
240+ cid = self ._cnt
241+ self ._observers [cid ] = func
242+ self ._cnt += 1
228243 return cid
229244
230245 def disconnect (self , cid ):
231246 """Remove the callback function with connection id *cid*."""
232247 try :
233- del self .observers [cid ]
248+ del self ._observers [cid ]
234249 except KeyError :
235250 pass
236251
@@ -382,11 +397,21 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
382397 verticalalignment = 'center' ,
383398 horizontalalignment = 'left' )
384399
385- self .cnt = 0
386- self .observers = {}
400+ self ._cnt = 0
401+ self ._observers = {}
387402
388403 self .set_val (valinit )
389404
405+ @cbook .deprecated ("3.4" )
406+ @property
407+ def cnt (self ):
408+ return self ._cnt
409+
410+ @cbook .deprecated ("3.4" )
411+ @property
412+ def observers (self ):
413+ return self ._observers
414+
390415 def _value_in_bounds (self , val ):
391416 """Makes sure *val* is with given bounds."""
392417 if self .valstep :
@@ -469,7 +494,7 @@ def set_val(self, val):
469494 self .val = val
470495 if not self .eventson :
471496 return
472- for cid , func in self .observers .items ():
497+ for cid , func in self ._observers .items ():
473498 func (val )
474499
475500 def on_changed (self , func ):
@@ -488,9 +513,9 @@ def on_changed(self, func):
488513 int
489514 Connection id (which can be used to disconnect *func*)
490515 """
491- cid = self .cnt
492- self .observers [cid ] = func
493- self .cnt += 1
516+ cid = self ._cnt
517+ self ._observers [cid ] = func
518+ self ._cnt += 1
494519 return cid
495520
496521 def disconnect (self , cid ):
@@ -503,7 +528,7 @@ def disconnect(self, cid):
503528 Connection id of the observer to be removed
504529 """
505530 try :
506- del self .observers [cid ]
531+ del self ._observers [cid ]
507532 except KeyError :
508533 pass
509534
@@ -600,8 +625,18 @@ def __init__(self, ax, labels, actives=None):
600625
601626 self .connect_event ('button_press_event' , self ._clicked )
602627
603- self .cnt = 0
604- self .observers = {}
628+ self ._cnt = 0
629+ self ._observers = {}
630+
631+ @cbook .deprecated ("3.4" )
632+ @property
633+ def cnt (self ):
634+ return self ._cnt
635+
636+ @cbook .deprecated ("3.4" )
637+ @property
638+ def observers (self ):
639+ return self ._observers
605640
606641 def _clicked (self , event ):
607642 if self .ignore (event ) or event .button != 1 or event .inaxes != self .ax :
@@ -640,7 +675,7 @@ def set_active(self, index):
640675
641676 if not self .eventson :
642677 return
643- for cid , func in self .observers .items ():
678+ for cid , func in self ._observers .items ():
644679 func (self .labels [index ].get_text ())
645680
646681 def get_status (self ):
@@ -655,15 +690,15 @@ def on_clicked(self, func):
655690
656691 Returns a connection id, which can be used to disconnect the callback.
657692 """
658- cid = self .cnt
659- self .observers [cid ] = func
660- self .cnt += 1
693+ cid = self ._cnt
694+ self ._observers [cid ] = func
695+ self ._cnt += 1
661696 return cid
662697
663698 def disconnect (self , cid ):
664699 """Remove the observer with connection id *cid*."""
665700 try :
666- del self .observers [cid ]
701+ del self ._observers [cid ]
667702 except KeyError :
668703 pass
669704
@@ -725,9 +760,9 @@ def __init__(self, ax, label, initial='',
725760 self .DIST_FROM_LEFT , 0.5 , initial , transform = self .ax .transAxes ,
726761 verticalalignment = 'center' , horizontalalignment = 'left' )
727762
728- self .cnt = 0
729- self .change_observers = {}
730- self .submit_observers = {}
763+ self ._cnt = 0
764+ self ._change_observers = {}
765+ self ._submit_observers = {}
731766
732767 ax .set (
733768 xlim = (0 , 1 ), ylim = (0 , 1 ), # s.t. cursor appears from first click.
@@ -750,6 +785,21 @@ def __init__(self, ax, label, initial='',
750785
751786 self .capturekeystrokes = False
752787
788+ @cbook .deprecated ("3.4" )
789+ @property
790+ def cnt (self ):
791+ return self ._cnt
792+
793+ @cbook .deprecated ("3.4" )
794+ @property
795+ def change_observers (self ):
796+ return self ._change_observers
797+
798+ @cbook .deprecated ("3.4" )
799+ @property
800+ def submit_observers (self ):
801+ return self ._submit_observers
802+
753803 @property
754804 def text (self ):
755805 return self .text_disp .get_text ()
@@ -780,7 +830,7 @@ def _rendercursor(self):
780830
781831 def _notify_submit_observers (self ):
782832 if self .eventson :
783- for cid , func in self .submit_observers .items ():
833+ for cid , func in self ._submit_observers .items ():
784834 func (self .text )
785835
786836 def _release (self , event ):
@@ -836,7 +886,7 @@ def set_val(self, val):
836886
837887 def _notify_change_observers (self ):
838888 if self .eventson :
839- for cid , func in self .change_observers .items ():
889+ for cid , func in self ._change_observers .items ():
840890 func (self .text )
841891
842892 def begin_typing (self , x ):
@@ -918,9 +968,9 @@ def on_text_change(self, func):
918968
919969 A connection id is returned which can be used to disconnect.
920970 """
921- cid = self .cnt
922- self .change_observers [cid ] = func
923- self .cnt += 1
971+ cid = self ._cnt
972+ self ._change_observers [cid ] = func
973+ self ._cnt += 1
924974 return cid
925975
926976 def on_submit (self , func ):
@@ -930,14 +980,14 @@ def on_submit(self, func):
930980
931981 A connection id is returned which can be used to disconnect.
932982 """
933- cid = self .cnt
934- self .submit_observers [cid ] = func
935- self .cnt += 1
983+ cid = self ._cnt
984+ self ._submit_observers [cid ] = func
985+ self ._cnt += 1
936986 return cid
937987
938988 def disconnect (self , cid ):
939989 """Remove the observer with connection id *cid*."""
940- for reg in [self .change_observers , self .submit_observers ]:
990+ for reg in [self ._change_observers , self ._submit_observers ]:
941991 try :
942992 del reg [cid ]
943993 except KeyError :
@@ -1022,8 +1072,18 @@ def __init__(self, ax, labels, active=0, activecolor='blue'):
10221072
10231073 self .connect_event ('button_press_event' , self ._clicked )
10241074
1025- self .cnt = 0
1026- self .observers = {}
1075+ self ._cnt = 0
1076+ self ._observers = {}
1077+
1078+ @cbook .deprecated ("3.4" )
1079+ @property
1080+ def cnt (self ):
1081+ return self ._cnt
1082+
1083+ @cbook .deprecated ("3.4" )
1084+ @property
1085+ def observers (self ):
1086+ return self ._observers
10271087
10281088 def _clicked (self , event ):
10291089 if self .ignore (event ) or event .button != 1 or event .inaxes != self .ax :
@@ -1061,7 +1121,7 @@ def set_active(self, index):
10611121
10621122 if not self .eventson :
10631123 return
1064- for cid , func in self .observers .items ():
1124+ for cid , func in self ._observers .items ():
10651125 func (self .labels [index ].get_text ())
10661126
10671127 def on_clicked (self , func ):
@@ -1070,15 +1130,15 @@ def on_clicked(self, func):
10701130
10711131 Returns a connection id, which can be used to disconnect the callback.
10721132 """
1073- cid = self .cnt
1074- self .observers [cid ] = func
1075- self .cnt += 1
1133+ cid = self ._cnt
1134+ self ._observers [cid ] = func
1135+ self ._cnt += 1
10761136 return cid
10771137
10781138 def disconnect (self , cid ):
10791139 """Remove the observer with connection id *cid*."""
10801140 try :
1081- del self .observers [cid ]
1141+ del self ._observers [cid ]
10821142 except KeyError :
10831143 pass
10841144
0 commit comments