Missing icons when running Notepad example on Raspberry Pi

Heads up! You've already completed this tutorial.

Anonymous asks

The notepad application example runs without problems on my Raspberry Pi. But the menu bar shows no icons. just blank rectangles. They do work if I click on them. What could be the problem?


Luca

Open the file notepad.py and go after this:

python
def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

add the following lines:

python
    icon = QIcon(os.path.join('images', 'blue-flolder-open-document.png'))
    print("availableSizes:", icon.availableSizes())

the output on the terminal should be:

python
 availableSizes: [PyQt5.QtCore.QSize(16, 16)]

if it is different, for example:

Create GUI Applications with Python & Qt5 by Martin Fitzpatrick — (PyQt5 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!

More info Get the book

python
availableSizes: []

try to replace all the occurrences of:

python
join('images',

to:

Over 10,000 developers have bought Create GUI Applications with Python & Qt!
Create GUI Applications with Python & Qt6
Take a look

Downloadable ebook (PDF, ePub) & Complete Source code

Also available from Leanpub and Amazon Paperback

[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]

python
join(path,

where path is the absolute path of your images folder for example:

python
path = '/home/USER_NAME/notepad/forum/images'

if the notepad folder is in the USER_NAME folder.

PyQt/PySide 1:1 Coaching with Martin Fitzpatrick — Get one on one help with your Python GUI projects. Working together with you I'll identify issues and suggest fixes, from bugs and usability to architecture and maintainability.

Book Now 60 mins ($195)

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

Missing icons when running Notepad example on Raspberry Pi was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt. Martin founded PythonGUIs to provide easy to follow GUI programming tutorials to the Python community. He has written a number of popular https://www.martinfitzpatrick.com/browse/books/ on the subject.