@@ -660,14 +660,19 @@ class NavigationToolbar2QT(NavigationToolbar2, QtWidgets.QToolBar):
660660 def __init__ (self , canvas , parent , coordinates = True ):
661661 """coordinates: should we show the coordinates on the right?"""
662662 self .canvas = canvas
663- self .parent = parent
663+ self ._parent = parent
664664 self .coordinates = coordinates
665665 self ._actions = {}
666666 """A mapping of toolitem method names to their QActions"""
667667
668668 QtWidgets .QToolBar .__init__ (self , parent )
669669 NavigationToolbar2 .__init__ (self , canvas )
670670
671+ @cbook .deprecated ("3.3" , alternative = "self.canvas.parent()" )
672+ @property
673+ def parent (self ):
674+ return self ._parent
675+
671676 def _icon (self , name , color = None ):
672677 if is_pyqt5 ():
673678 name = name .replace ('.png' , '_large.png' )
@@ -718,7 +723,7 @@ def edit_parameters(self):
718723 axes = self .canvas .figure .get_axes ()
719724 if not axes :
720725 QtWidgets .QMessageBox .warning (
721- self .parent , "Error" , "There are no axes to edit." )
726+ self .canvas . parent () , "Error" , "There are no axes to edit." )
722727 return
723728 elif len (axes ) == 1 :
724729 ax , = axes
@@ -735,7 +740,8 @@ def edit_parameters(self):
735740 if titles [i ] in duplicate_titles :
736741 titles [i ] += f" (id: { id (ax ):#x} )" # Deduplicate titles.
737742 item , ok = QtWidgets .QInputDialog .getItem (
738- self .parent , 'Customize' , 'Select axes:' , titles , 0 , False )
743+ self .canvas .parent (),
744+ 'Customize' , 'Select axes:' , titles , 0 , False )
739745 if not ok :
740746 return
741747 ax = axes [titles .index (item )]
0 commit comments