Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: Icons do not work with GTK #29229

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
bakku opened this issue Dec 4, 2024 · 9 comments · Fixed by #29295
Closed

[Bug]: Icons do not work with GTK #29229

bakku opened this issue Dec 4, 2024 · 9 comments · Fixed by #29295
Milestone

Comments

@bakku
Copy link

bakku commented Dec 4, 2024

Bug summary

When using GTK as backend, a bunch of warnings are shown in the terminal due to missing icons and the UI does not show icons in the toolbar.

Code for reproduction

import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 5])
plt.ylabel('some numbers')
plt.show()

Actual outcome

(python:35385): Gtk-WARNING **: 22:07:42.455: Failed to load icon <path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/home-symbolic.svg: Failed to open file “<path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/home-symbolic.svg”: No such file or directory

(python:35385): Gtk-WARNING **: 22:07:42.455: Failed to load icon <path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/back-symbolic.svg: Failed to open file “<path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/back-symbolic.svg”: No such file or directory

(python:35385): Gtk-WARNING **: 22:07:42.455: Failed to load icon <path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/forward-symbolic.svg: Failed to open file “<path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/forward-symbolic.svg”: No such file or directory

(python:35385): Gtk-WARNING **: 22:07:42.455: Failed to load icon<path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/move-symbolic.svg: Failed to open file “<path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/move-symbolic.svg”: No such file or directory

(python:35385): Gtk-WARNING **: 22:07:42.455: Failed to load icon <path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/zoom_to_rect-symbolic.svg: Failed to open file “<path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/zoom_to_rect-symbolic.svg”: No such file or directory

(python:35385): Gtk-WARNING **: 22:07:42.455: Failed to load icon <path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/subplots-symbolic.svg: Failed to open file “<path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/subplots-symbolic.svg”: No such file or directory

(python:35385): Gtk-WARNING **: 22:07:42.455: Failed to load icon <path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/filesave-symbolic.svg: Failed to open file “<path_to_project>/venv/lib/python3.13/site-packages/matplotlib/mpl-data/images/filesave-symbolic.svg”: No such file or directory

image

Expected outcome

Icons are shown properly

Additional information

Steps:

python -m venv venv
. venv/bin/activate
pip install -U pip
pip install -U matplotlib
pip install -U PyGObject

# put code for reproduction in a file `main.py`

python main.py

Operating system

Ubuntu

Matplotlib Version

3.9.3

Matplotlib Backend

gtk4agg

Python version

3.13.0

Jupyter version

No response

Installation

pip

@QuLogic
Copy link
Member

QuLogic commented Dec 5, 2024

Are the files from the warnings not there?

@ksunden
Copy link
Member

ksunden commented Dec 5, 2024

I've seen this before, it was resolved by installing an optional dependency, I want to say it was rsvg/librsvg, but not 100% sure.

Essentially our icons are now SVGs and GTK can support SVGs, but some base installs do not support it out of the box.

@bakku
Copy link
Author

bakku commented Dec 5, 2024

Yes, the files do not exist at all. pip install matplotlib does not download the matplotlib package with the symbolic links in the images folder:

$ ls -1 venv/lib/python3.13/site-packages/matplotlib/mpl-data/images
back_large.png
back.pdf
back.png
back.svg
filesave_large.png
filesave.pdf
filesave.png
filesave.svg
forward_large.png
forward.pdf
forward.png
forward.svg
hand.pdf
hand.png
hand.svg
help_large.png
help.pdf
help.png
help.svg
home_large.png
home.pdf
home.png
home.svg
matplotlib_large.png
matplotlib.pdf
matplotlib.png
matplotlib.svg
move_large.png
move.pdf
move.png
move.svg
qt4_editor_options_large.png
qt4_editor_options.pdf
qt4_editor_options.png
qt4_editor_options.svg
subplots_large.png
subplots.pdf
subplots.png
subplots.svg
zoom_to_rect_large.png
zoom_to_rect.pdf
zoom_to_rect.png
zoom_to_rect.svg

@2sn
Copy link

2sn commented Dec 10, 2024

I have the same issue with gtk on Linux (Python from source, matplotlib from Pip), as well as on Windows (WSL, Ubuntu 2022 LTS, Python 3.11.11).
screenshot
It all still works in Matplotlib 3.9.2

In principle, the missing icons can be fixed by creating symbolic links from the *.svg to *-symbolic.svg names. Probably some routine auto-generates the wrong file names, maybe done for testing/development and not switched back.

So it is not about installing packages, it is a bug; someone who did some refactor from, 3.9.2 to 3.9.3 messed up, and it was not caught by any quality control tests. It happens, but please fix in next version.

@greglucas
Copy link
Contributor

They are missing from the distributed wheels. But, building a wheel locally I get them built into the wheels.

A quick grep of the library looks like this is basically the only place we are referencing -symbolic for the icons, is there a reason we need the -symbolic or can we just point to the actual distributed images?

@greglucas
Copy link
Contributor

So it is not about installing packages, it is a bug; someone who did some refactor from, 3.9.2 to 3.9.3 messed up, and it was not caught by any quality control tests. It happens, but please fix in next version.

We do not know it was someone who messed up. This could be an upstream issue with cibuildwheel/meson changing how they reference symlinks. @2sn, please do not accuse people in your comments, we are a community of volunteers. If you want to investigate this and help contribute a patch that would be greatly appreciated!

@SoundDesignerToBe
Copy link

SoundDesignerToBe commented Dec 12, 2024

I just spent a few hours identifying this bug, too. I have a Gtk 3 app bundled in a flatpak file that uses matplotlib backendtools. In my case, button labels were shown instead of their icons. But I saw no error or warning messages, so this was a tough one

@QuLogic
Copy link
Member

QuLogic commented Dec 12, 2024

A quick grep of the library looks like this is basically the only place we are referencing -symbolic for the icons, is there a reason we need the -symbolic or can we just point to the actual distributed images?

Though mentioned in the meeting, for reference here, the naming triggers GTK's symbolic icon support which re-colours the icons based on user theme (white strokes on dark backgrounds, black stroke on light backgrounds, etc.)

@2sn
Copy link

2sn commented Dec 12, 2024

@greglucas My apologies. My questions is whether it is possible to create a test setup to check for this kind of issues? It seems to have escaped automated tests.

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.

6 participants