Skip to content

Error using "set_window_title" for canvas via backend_qt5agg #17716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xo-HADES-xo opened this issue Jun 22, 2020 · 8 comments · Fixed by #17720
Closed

Error using "set_window_title" for canvas via backend_qt5agg #17716

xo-HADES-xo opened this issue Jun 22, 2020 · 8 comments · Fixed by #17720
Milestone

Comments

@xo-HADES-xo
Copy link

xo-HADES-xo commented Jun 22, 2020

Bug summary
When using "set_window_title" I get this error:
self.manager.set_window_title(title)
AttributeError: 'NoneType' object has no attribute 'set_window_title'

Located in this file and error:
File "..\lib\site-packages\matplotlib\backend_bases.py", line 2245, in set_window_title
self.manager.set_window_title(title)
AttributeError: 'NoneType' object has no attribute 'set_window_title'

Code for reproduction
self.canvas.set_window_title('Some Text')

  • Operating system: Win 10
  • Matplotlib version: 3.3.0rc1
  • Matplotlib backend (print(matplotlib.get_backend())): matplotlib.backends.backend_qt5agg
  • Python version: 3.7.7
  • Other libraries: PyQt5: 5.15.0
pip
@tacaswell
Copy link
Member

Can you provide a more complete example that reproduces the problem?

@tacaswell
Copy link
Member

Also, thank you for testing the RC 😄

@xo-HADES-xo
Copy link
Author

xo-HADES-xo commented Jun 22, 2020

Here is a code example that shows issue.
When removing "self.canvas1.set_window_title('Title Test')" program runs with no errors.

# -*- coding: utf-8 -*-

from PyQt5 import QtCore, QtGui, QtWidgets

import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from PyQt5 import QtCore


class Ui_Form(object):

    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(745, 556)
        self.verticalLayout = QtWidgets.QVBoxLayout(Form)
        self.verticalLayout.setObjectName("verticalLayout")
        QtCore.QMetaObject.connectSlotsByName(Form)

        #
        self.setup_plot()

    def setup_plot(self):
        dpi = 75
        fig1 = plt.figure(dpi=dpi, facecolor='#617f8a', tight_layout=True)
        mpl.rc('axes', facecolor='#ffffff')
        self.plot1 = fig1.add_subplot(111)
        self.canvas1 = FigureCanvas(fig1)
        self.verticalLayout.addWidget(self.canvas1)
        toolbar = NavigationToolbar(self.canvas1, self.canvas1)
        toolbar.setMaximumSize(QtCore.QSize(16777215, 35))
        self.verticalLayout.addWidget(toolbar)
        self.canvas1.set_window_title('Title Test')


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()
    sys.exit(app.exec_())

[@tacaswell edited to add multi-line markup]

@tacaswell tacaswell added this to the v3.3.0 milestone Jun 22, 2020
@tacaswell
Copy link
Member

Thanks @NHades !

@xo-HADES-xo
Copy link
Author

Thanks for fast response!

@H-tr
Copy link

H-tr commented Sep 27, 2023

Hi, is this issue fixed? currently I'm still facing same issue with matplotlib==3.7.3

@QuLogic
Copy link
Member

QuLogic commented Sep 27, 2023

Please open a new issue with a specific reproducer if you are still seeing this problem.

@H-tr
Copy link

H-tr commented Sep 27, 2023

I found the solution. Thanks for your reply and have a good day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants