@@ -660,14 +660,19 @@ class NavigationToolbar2QT(NavigationToolbar2, QtWidgets.QToolBar):
660
660
def __init__ (self , canvas , parent , coordinates = True ):
661
661
"""coordinates: should we show the coordinates on the right?"""
662
662
self .canvas = canvas
663
- self .parent = parent
663
+ self ._parent = parent
664
664
self .coordinates = coordinates
665
665
self ._actions = {}
666
666
"""A mapping of toolitem method names to their QActions"""
667
667
668
668
QtWidgets .QToolBar .__init__ (self , parent )
669
669
NavigationToolbar2 .__init__ (self , canvas )
670
670
671
+ @cbook .deprecated ("3.3" , alternative = "self.canvas.parent()" )
672
+ @property
673
+ def parent (self ):
674
+ return self ._parent
675
+
671
676
def _icon (self , name , color = None ):
672
677
if is_pyqt5 ():
673
678
name = name .replace ('.png' , '_large.png' )
@@ -718,7 +723,7 @@ def edit_parameters(self):
718
723
axes = self .canvas .figure .get_axes ()
719
724
if not axes :
720
725
QtWidgets .QMessageBox .warning (
721
- self .parent , "Error" , "There are no axes to edit." )
726
+ self .canvas . parent () , "Error" , "There are no axes to edit." )
722
727
return
723
728
elif len (axes ) == 1 :
724
729
ax , = axes
@@ -735,7 +740,8 @@ def edit_parameters(self):
735
740
if titles [i ] in duplicate_titles :
736
741
titles [i ] += f" (id: { id (ax ):#x} )" # Deduplicate titles.
737
742
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 )
739
745
if not ok :
740
746
return
741
747
ax = axes [titles .index (item )]
0 commit comments