[Matplotlib-users] R: Problem with MatplotLib embedded in PyQt5

m.dilorenzo at nanotechanalysis.com m.dilorenzo at nanotechanalysis.com
Thu May 7 04:55:52 EDT 2020


Hello All,

 

Problem solved!

 

I had inadvertently removed the flag to be enabled in the widget in Qtdesigner.

My bug research was focused on my application files instead of ui files… 🙄

 

Anyway I’d like to highlight a lack of info on the NavigationToolbar2QT API interface (at least I can0t find it).

 

Best regards,

Maurizio 

 

 

Da: Matplotlib-users <matplotlib-users-bounces+m.dilorenzo=nanotechanalysis.com at python.org> Per conto di m.dilorenzo at nanotechanalysis.com
Inviato: martedì 5 maggio 2020 10:51
A: matplotlib-users at python.org
Oggetto: [Matplotlib-users] Problem with MatplotLib embedded in PyQt5

 

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/20200507/8384bb20/attachment.html>


More information about the Matplotlib-users mailing list