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:

Packaging Python Applications with PyInstaller by Martin Fitzpatrick — This step-by-step guide walks you through packaging your own Python applications from simple examples to complete installers and signed executables.

More info Get the book

python
availableSizes: []

try to replace all the occurrences of:

python
join('images',

to:

Bring Your PyQt/PySide Application to Market — Stuck in development hell? I'll help you get your project focused, finished and released. Benefit from years of practical experience releasing software with Python.

Find out More

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.

1:1 Coaching & Tutoring for your Python GUIs project
Martin Fitzpatrick Python GUIs Coaching & Training
60 mins ($195) Book Now

1:1 Python GUIs Coaching & Training

Comprehensive code reviewBugfixes & improvements • Maintainability advice and architecture improvements • Design and usability assessment • Suggestions and tips to expand your knowledgePackaging and distribution help for Windows, Mac & Linux • Find out more.

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 Python books on the subject.