Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Félix Hartmann
XyDyS
Commits
3c98ea6a
Commit
3c98ea6a
authored
May 14, 2019
by
Félix Hartmann
Browse files
Set backend to PyQt5.
parent
c6c9e378
Changes
2
Hide whitespace changes
Inline
Side-by-side
init.py
View file @
3c98ea6a
...
...
@@ -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
...
...
mplfigure_qt.py
View file @
3c98ea6a
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment