@@ -160,46 +160,6 @@ def _create_qApp():
160160 return app
161161
162162
163- def _allow_super_init (__init__ ):
164- """
165- Decorator for ``__init__`` to allow ``super().__init__`` on PySide2.
166- """
167-
168- if QT_API in ["PyQt5" , "PyQt6" ]:
169-
170- return __init__
171-
172- else :
173- # To work around lack of cooperative inheritance in PySide2 and
174- # PySide6, when calling FigureCanvasQT.__init__, we temporarily patch
175- # QWidget.__init__ by a cooperative version, that first calls
176- # QWidget.__init__ with no additional arguments, and then finds the
177- # next class in the MRO with an __init__ that does support cooperative
178- # inheritance (i.e., not defined by the PyQt4 or sip, or PySide{,2,6}
179- # or Shiboken packages), and manually call its `__init__`, once again
180- # passing the additional arguments.
181-
182- qwidget_init = QtWidgets .QWidget .__init__
183-
184- def cooperative_qwidget_init (self , * args , ** kwargs ):
185- qwidget_init (self )
186- mro = type (self ).__mro__
187- next_coop_init = next (
188- cls for cls in mro [mro .index (QtWidgets .QWidget ) + 1 :]
189- if cls .__module__ .split ("." )[0 ] not in [
190- "PySide2" , "PySide6" , "Shiboken" ,
191- ])
192- next_coop_init .__init__ (self , * args , ** kwargs )
193-
194- @functools .wraps (__init__ )
195- def wrapper (self , * args , ** kwargs ):
196- with cbook ._setattr_cm (QtWidgets .QWidget ,
197- __init__ = cooperative_qwidget_init ):
198- __init__ (self , * args , ** kwargs )
199-
200- return wrapper
201-
202-
203163class TimerQT (TimerBase ):
204164 """Subclass of `.TimerBase` using QTimer events."""
205165
@@ -229,7 +189,7 @@ def _timer_stop(self):
229189 self ._timer .stop ()
230190
231191
232- class FigureCanvasQT (QtWidgets .QWidget , FigureCanvasBase ):
192+ class FigureCanvasQT (FigureCanvasBase , QtWidgets .QWidget ):
233193 required_interactive_framework = "qt"
234194 _timer_cls = TimerQT
235195 manager_class = _api .classproperty (lambda cls : FigureManagerQT )
@@ -244,7 +204,6 @@ class FigureCanvasQT(QtWidgets.QWidget, FigureCanvasBase):
244204 ]
245205 }
246206
247- @_allow_super_init
248207 def __init__ (self , figure = None ):
249208 _create_qApp ()
250209 super ().__init__ (figure = figure )
0 commit comments