Open cragginstylie opened 2 years ago
Hi,
the first error you got pygame.error: font not initialized
is telling that you didn't initialized pygame.
Check in your /home/pi/TGR-A8D4-TPL-R1/ui/objs.py
module that you called pygame.init()
before creating the keyboard.
Try also pygame.font.init()
if still not working
--- do typical initialization ---
In my op, means I called pygame.init(). Like I said, I've seen this before from other pygame related modules, and it's caused by a mismatch of initialized data structures. I'm including pygame_sdl2, along with pygame_sdl2.init(), which doesn't jive with a module that's including pygame and expecting pygame.init() to have been executed. You can try calling pygame.font.init() till the cows come home, and it will never work due to the mismatch between the actual pygame module being referenced.
Ok, I see. But the lib is not forseen for pygame_sdl2 (I didn't paid attention that it is a fork of pygame for SDL2)
If you need SDL2, you could install pygame>2.0 which is fully compatible with SDL2
If you need SDL2, you could install pygame>2.0 which is fully compatible with SDL2
I tried that, but apt forces an upgrade of the default installed pygame 1.9.6 package, which doesn't have compatibility with the kmsd video driver needed to support the HDMI touch screen device. The only pygame package that works on this system is the pygame_sdl2. FWIW - this would work fine on an RPi 3B+, which uses the standard fbdev or fbturbo drivers. I migrated to RPi 4B to get more CPU & memory, which is a consequence of adding more & more capabilities to my project. /sigh
I'm able to install it on Pi OS Buster using the commands:
sudo apt-get install libsdl2-*
sudo pip3 install pygame>=2.0
An other way could be tweak python import system. Something like that (I didn't test):
import pygame_sdl2
import sys
sys.modules['pygame']=pygame_sdl2
from pygame_vkeyboard import *
I'm using Raspbian Bullseye 64bit, and it's not the package installation having issues. It's the lack of kmsd driver support compiled in, which causes pygame.display.init() to throw errors about inability to find a driver.
Understood. I know that Bullseye it's still young and buggy. That why I didn't switched on yet.
An other way could be tweak python import system. Something like that (I didn't test):
import pygame_sdl2 import sys sys.modules['pygame']=pygame_sdl2 from pygame_vkeyboard import *
Wouldn't that be similar to editing the vkeyboard .py files as I mentioned in my op? Willing to give it a go, but I'm skeptical...
Understood. I know that Bullseye it's still young and buggy. That why I didn't switched on yet.
Actually, on an RPi 4, it runs with fewer issues. At least so far.
Yes it will be similar Thant editing files.
The error you point out is probably du to the fact that pygame2
and pygame_sdl2
do not work exactly on the same way.
I think that the main reason is that pygame_sdl2
is compiled using cython
. It require to respect some coding rules in order to be compliant.
For instance, the error that you are pointing out is about the comparison:
if self.sprites.get_clip() != clip_rect:
self.sprites.get_clip()
return None
and clip_rect
is a Rect
object:
NoneType
(I'm only making supposition)So if you replace the comparison by (which is also completely acceptable in python but more verbose):
if self.sprites.get_clip() is None or self.sprites.get_clip() != clip_rect:
The error could gone. But probably to go to the next one until all part of the code is made compatible. It is a fastidious work. But if you want, you can propose a PR.
It is a fastidious work. But if you want, you can propose a PR.
Haha! Agreed. ATM, I'm going to proceed with my UI design to not include any capabilities requiring keyboard input. I've built my IoT device to support a touchscreen for physical proximity, and a web console for remote access. Functions requiring a keyboard (like naming devices, timers, or presets) will have to remain relegated to the web console (for now).
Hi!
I found your project and think it would be perfect to include as part of mine. Here's the project hardware/software I'm using:
I'm forced to use the python3-pygame-sdl2 package because the default pygame 1.9.6 package does not support the kernel mode video drivers on an RPi 4, consistently throwing errors about unable to initialize the display or unable to open a console. The sdl2 package works with my drivers as expected.
However, I tried to get your module to work, but it throws various errors because of the (I assume significant) differences between pygame 2.x compiled with SDL2 support. Here's what I tried so far:
Which produces the following error:
I've seen this error before with other pygame modules (pygame_gui, for example). I then edited the .py files within your module package to reference pygame_sdl2 instead of pygame. This produces the following error:
At this point, it would be diving too far down the rabbit hole to get it working only to find out it still doesn't fit my needs. I believe it will, but truthfully would need assistance trying to port this over.
Not sure this is something you're even willing & able to tackle, but thought it won't hurt to ask. Totally understandable if not.