[Matplotlib-users] Problem with MatplotLib embedded in PyQt5

m.dilorenzo at nanotechanalysis.com m.dilorenzo at nanotechanalysis.com
Tue May 5 04:50:46 EDT 2020


Hello,

 

I'm using a matplotlib plot embedded into a PyQt5 GUI.

 

After some modification the figure toolbar became grayed (visible but not
active) and no action is feasible anymore on the plot during running.

In the previous program versions it works, incidentally I guess since the
modifications I've made are only on the computational parts of the code.

 

Is there a way to control the activation of these interactive settings (I
really need to zoom and rotate 3d graph while running.).

 

I've already tried with setfocus command but no joy (I don't relay
understand how the focus is managed .)

 

Any help is welcome.

 

Thank you in advance and best regards.

 

Maurizio

 

Some souce code: widget class promoted inside a QTDesigner UI

 

# ------------------------------------------------------

# -------------------- mplwidget.py --------------------

# ------------------------------------------------------

from PyQt5.QtWidgets import *

 

from matplotlib.backends.backend_qt5agg import FigureCanvas ,
NavigationToolbar2QT as NavigationToolbar

 

from matplotlib.figure import Figure

 

    

class MplWidget(QWidget):

    

    def __init__(self, parent = None):

 

        QWidget.__init__(self, parent)

        

        #self.figure = Figure()

        self.canvas = FigureCanvas(Figure(constrained_layout=True))

        self.toolbar = NavigationToolbar(self.canvas, self)

 

        vertical_layout = QVBoxLayout()

        vertical_layout.addWidget(self.toolbar)

        vertical_layout.addWidget(self.canvas)

        self.canvas.axesMain = self.canvas.figure.add_subplot(111)

        self.setLayout(vertical_layout)

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20200505/5e78f996/attachment.html>


More information about the Matplotlib-users mailing list