Problem with MatplotLib embedded in PyQt5

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with MatplotLib embedded in PyQt5

m.dilorenzo

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__(selfparent = 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)

 

 

 


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

R: Problem with MatplotLib embedded in PyQt5

m.dilorenzo

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=[hidden email]> Per conto di [hidden email]
Inviato: martedì 5 maggio 2020 10:51
A: [hidden email]
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__(selfparent = 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)

 

 

 


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users