@@ -1057,6 +1057,7 @@ class itself will store the flag and the ``_on_timer`` method should be
10571057 timer events. This list can be manipulated directly, or the
10581058 functions `add_callback` and `remove_callback` can be used.
10591059 """
1060+
10601061 def __init__ (self , interval = None , callbacks = None ):
10611062 #Initialize empty callbacks list and setup default settings if necssary
10621063 if callbacks is None :
@@ -2222,15 +2223,19 @@ def mpl_disconnect(self, cid):
22222223 """
22232224 return self .callbacks .disconnect (cid )
22242225
2225- def new_timer (self , * args , ** kwargs ):
2226+ # Internal subclasses can override _timer_cls instead of new_timer, though
2227+ # this is not a public API for third-party subclasses.
2228+ _timer_cls = TimerBase
2229+
2230+ def new_timer (self , interval = None , callbacks = None ):
22262231 """
22272232 Create a new backend-specific subclass of `.Timer`.
22282233
22292234 This is useful for getting periodic events through the backend's native
22302235 event loop. Implemented only for backends with GUIs.
22312236
2232- Other Parameters
2233- ----------------
2237+ Parameters
2238+ ----------
22342239 interval : int
22352240 Timer interval in milliseconds.
22362241
@@ -2243,9 +2248,9 @@ def new_timer(self, *args, **kwargs):
22432248
22442249 Examples
22452250 --------
2246- >>> timer = fig.canvas.new_timer(callbacks=[(f1, (1, ), {'a': 3}), ])
2251+ >>> timer = fig.canvas.new_timer(callbacks=[(f1, (1,), {'a': 3})])
22472252 """
2248- return TimerBase ( * args , ** kwargs )
2253+ return self . _timer_cls ( interval = interval , callbacks = callbacks )
22492254
22502255 def flush_events (self ):
22512256 """
0 commit comments