Commit 3c98ea6a authored by Félix Hartmann's avatar Félix Hartmann
Browse files

Set backend to PyQt5.

parent c6c9e378
......@@ -4,10 +4,8 @@
from __future__ import (unicode_literals, absolute_import, division,
print_function)
from traits.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'qt'
import matplotlib as mpl
mpl.use("Qt5Agg")
from controlpanel import ControlPanel
......
......@@ -7,17 +7,20 @@ pointed out to me by Pierre Haessig, March 2014
Source:
http://enthought-dev.117412.n3.nabble.com/traitsui-matplotlib-editor-with-toolbar-using-qt-backend-td4026437.html
April 2019: a few changes for accomodating PyQt5, based on
https://pythonspot.com/pyqt5-matplotlib/
"""
from pyface.qt import QtGui
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from PyQt5.QtWidgets import QWidget, QVBoxLayout
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT
from matplotlib.figure import Figure
# from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT
from traits.api import Instance
from traitsui.qt4.editor import Editor
from traitsui.qt4.basic_editor_factory import BasicEditorFactory
# 'qt4' is for compatibility, and will be probably replaced with 'qt' in the future
class _MPLFigureEditor(Editor):
......@@ -32,15 +35,13 @@ class _MPLFigureEditor(Editor):
pass
def _create_canvas(self, parent):
""" Create the MPL canvas. """
# matplotlib commands to create a canvas
frame = QtGui.QWidget()
"""Create the MPL canvas."""
frame = QWidget()
mpl_canvas = FigureCanvas(self.value)
mpl_canvas.setParent(frame)
# mpl_toolbar = NavigationToolbar2QTAgg(mpl_canvas,frame)
mpl_toolbar = NavigationToolbar2QT(mpl_canvas, frame)
vbox = QtGui.QVBoxLayout()
vbox = QVBoxLayout()
vbox.addWidget(mpl_canvas)
vbox.addWidget(mpl_toolbar)
frame.setLayout(vbox)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment