3838import os
3939import matplotlib
4040
41- import matplotlib as mpl
42- print ('matplotlib version: ' , mpl .__version__ )
41+ print ('matplotlib version: ' , matplotlib .__version__ )
4342
4443import gpi
4544from gpi import QtCore , QtGui , QtWidgets
4645
4746import numpy as np
4847from matplotlib .figure import Figure
4948#from matplotlib.backend_bases import key_press_handler
50- from matplotlib .backends .backend_qt4agg import (
51- FigureCanvasQTAgg as FigureCanvas ,
52- NavigationToolbar2QT as NavigationToolbar )
53- from matplotlib .backends .backend_qt4 import SubplotToolQt
49+ from matplotlib .backends .backend_qt5agg import (
50+ FigureCanvas , NavigationToolbar2QT as NavigationToolbar )
51+ from matplotlib .backends .backend_qt5 import SubplotToolQt
5452
5553class MainWin_close (QtWidgets .QMainWindow ):
5654 window_closed = gpi .Signal ()
@@ -104,8 +102,6 @@ def _init_toolbar(self):
104102 if tooltip_text is not None :
105103 a .setToolTip (tooltip_text )
106104
107- self .buttons = {}
108-
109105 # Add the x,y location widget at the right side of the toolbar
110106 # The stretch factor is 1 which means any resizing of the toolbar
111107 # will resize this label instead of the buttons.
@@ -119,9 +115,6 @@ def _init_toolbar(self):
119115 labelAction = self .addWidget (self .locLabel )
120116 labelAction .setVisible (True )
121117
122- # reference holder for subplots_adjust window
123- self .adj_window = None
124-
125118###############################################################################
126119# -*- coding: utf-8 -*-
127120#
@@ -135,19 +128,14 @@ def _init_toolbar(self):
135128import os .path as osp
136129
137130try :
138- import matplotlib .backends .qt4_editor .formlayout as formlayout
131+ import matplotlib .backends .qt_editor .formlayout as formlayout
139132except :
140- try :
141- import matplotlib .backends .qt_editor .formlayout as formlayout
142- except :
143- formlayout = None
144- print ("formlayout can't be found, line options will be disabled" )
133+ formlayout = None
134+ print ("formlayout can't be found, line options will be disabled" )
145135
146- #from matplotlib.backends.qt4_compat import QtGui
147136from matplotlib import markers
148137
149138def get_icon (name ):
150- import matplotlib
151139 basedir = osp .join (matplotlib .rcParams ['datapath' ], 'images' )
152140 return QtGui .QIcon (osp .join (basedir , name ))
153141
@@ -268,7 +256,6 @@ def apply_callback(data):
268256 figure = axes .get_figure ()
269257 figure .canvas .draw ()
270258
271- # formlayout disappears in matplotlib 1.4.0
272259 if formlayout is not None :
273260 data = formlayout .fedit (datalist , title = "Figure options" , parent = parent , icon = get_icon ('qt4_editor_options.svg' ), apply = apply_callback )
274261
@@ -996,8 +983,10 @@ def on_key_press(self, event):
996983
997984class ExternalNode (gpi .NodeAPI ):
998985
999- """A Qt embedded plot window using the code from:
986+ """A Qt embedded plot window originally using the code from:
1000987 http://matplotlib.org/examples/user_interfaces/embedding_in_qt4_wtoolbar.html
988+ Updated by DDB in Feb. 2020 using the qt5 code from:
989+ https://matplotlib.org/examples/user_interfaces/embedding_in_qt5.html
1001990 keyboard shortcuts can be found here:
1002991 http://matplotlib.org/users/navigation_toolbar.html#navigation-keyboard-shortcuts
1003992
0 commit comments