Skip to content
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

Pygame_GUI on a Raspberry Pi Zero2 without desktop cannot find default font #612

Open
dickh768 opened this issue Jul 3, 2024 · 3 comments

Comments

@dickh768
Copy link

dickh768 commented Jul 3, 2024

I have a simple GUI app running on a Raspberry Pi Zero 2 with desktop which runs well but I would like to drop the desktop since it uses resources which are in short supply on the Zero2. (only 0.5GB memory in particular). Pygame itself seems to run successfully without the desktop provided that SDL2 is installed. However, as soon as the Pygame_GUI manager is invoked, the script errors with:

Traceback (most recent call last):
File "/home/dickh/test.py", line 10, in
manager = pygame_gui.UIManager((480,320))
File "/usr/local/lib/python3.9/dist-packages/pygame_gui-0.6.12-py3.9.egg/pygame_gui/ui_manager.py", line 70, in init
self.ui_theme = self.create_new_theme(theme_path)
File "/usr/local/lib/python3.9/dist-packages/pygame_gui-0.6.12-py3.9.egg/pygame_gui/ui_manager.py", line 117, in create_new_theme
theme = UIAppearanceTheme(self.resource_loader, self._locale)
File "/usr/local/lib/python3.9/dist-packages/pygame_gui-0.6.12-py3.9.egg/pygame_gui/core/ui_appearance_theme.py", line 62, in init
self.font_dict = UIFontDictionary(self._resource_loader, locale)
File "/usr/local/lib/python3.9/dist-packages/pygame_gui-0.6.12-py3.9.egg/pygame_gui/core/ui_font_dictionary.py", line 190, in init
self._load_default_font(self.default_font)
File "/usr/local/lib/python3.9/dist-packages/pygame_gui-0.6.12-py3.9.egg/pygame_gui/core/ui_font_dictionary.py", line 222, in _load_default_font
raise error
FileNotFoundError: Unable to load resource with path: pygame_gui.data.NotoSans-Regular.ttf

The above was obtained running a minimal script:

import pygame
import pygame_gui
pygame.init()
screen = pygame.display.set_mode([480,320])
manager = pygame_gui.UIManager((480,320))
pygame.display.set_caption("My Board")
exit = False
while not exit:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit = True
    pygame.display.update()

I have checked the install directories and all of the font files appear to be in the right place. For some reason this Pygame_GUI installation cannot find them. I initially installed v0.6.0 using PIP and have since tried installing 0.6.12 from source with the same result.

  • OS: Raspbian GNU/Linux 11 (bullseye)
    Kernel: Linux 6.1.21-v7+
    Architecture: arm 32bit

  • Pygame GUI version 0.6.12

  • Pygame-ce 2.5.0

  • SDL 2.0.14

  • Python 3.9.2)

@dickh768 dickh768 added the bug Something isn't working label Jul 3, 2024
@joereynolds
Copy link
Contributor

joereynolds commented Oct 18, 2024

I can see you're calling pygame.init() which should in turn call pygame.font.init() but can you try explicitly calling pygame.font.init() and seeing what happens?

pygame.init() silently fails when initting modules I think. Whereas if you do the font load explicitly it might give a bit more info to go off

@MyreMylar
Copy link
Owner

From what I understand SDL itself isn't running well without a desktop on Raspberry Pi at the minute - which is likely to be the root of the problem. The font file is presumably still where it normally is, I expect this error is a result of something cascading from deep in SDL, up through pygame and this is just the final error you are seeing. I would try loading font files with normal pygame code and see if you still get errors.

AFAICT there is nothing I can do about this in Pygame GUI itself, as you said it works fine on raspberry pi with the desktop.

I'll leave this open for now in case you have resolved it or can pin it down further, but I expect I will have to close this here.

@MyreMylar MyreMylar added SDL Raspberry Pi Lite and removed bug Something isn't working labels Nov 3, 2024
@TopherTimeMachine
Copy link

@dickh768 @MyreMylar

I'm getting this same issue on a Pi3 in Bullseye with desktop installed.

Raspbian GNU/Linux 11 (bullseye)
32bit
Pygame-ce 2.5.2
SDL 2.0.14
Python 3.9.2
Pygame GUI 0.6.12

Is there a way we could set what the default font is? or set the font location?
Wondering what a work around might be?

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

No branches or pull requests

4 participants