I'm hoping @geofft can fix this 2022 issue on #uv built #Python binaries that breaks #tkinter, wishing him best of luck!
https://github.com/astral-sh/python-build-standalone/issues/129#issuecomment-3016695658
I'm hoping @geofft can fix this 2022 issue on #uv built #Python binaries that breaks #tkinter, wishing him best of luck!
https://github.com/astral-sh/python-build-standalone/issues/129#issuecomment-3016695658
So... I wanted to package my Python app using tkinter UI library (it is just good enough for my purpose) as a flatpak. Flatpaks are based on "runtimes" similar to docker base images.
As I did obviously not use any "big" UI framework (Gnome or KDE) and it already provides Python with tkinter, I decided to use the org.freedesktop.Platform as a runtime for my flatpak. The first challenge was to get the dbus-python package to compile, as it requires a dbus binary for compiling it. So I added the freedesktop DBus implementation. I need dbus functionallity, as it allows me to use the "XDG Desktop Portals" to interactively open files when running in the flatpak sandbox. After this, everything worked!
Unfortunately, the application cannot load any proper font, so it falls back to the 90s era fonts compiled statically into Tcl/Tk (which tkinter is based on). After some trial and error, and finding out how add custom fonts to Tk, I disovered that the freedesktop runtime does not ship freedesktop fontconfig. And also I can't add it that easily to the build step, too, as the bundled Tk installation does not link to it anyway…
And just because it can, the Tkinter app automatically reconnects and resyncs the UI when the Teensy firmware changes.
11/∞
Now I have a working app. The table in the first screen capture is compiled into the Teensy. A Tkinter app on my Mac reads it and generates the UI in the second screen capture. All the controls change the sound in real time.
I can make several good drum sounds, and it's just a matter of tweaking them. The reverb sounds like a walkie-talkie in a bucket, though. I may have introduced a bug...
10/∞
I didn't find anything that would make it easy, so I started writing a UI from scratch. I spent a few hours in tkinter and knocked out a sketch of what I'm thinking of.
tkinter is weird. But it's mature and reasonably well documented.
Now I'll need to write a little bidirectional serial protocol so the Teensy can tell me what actual parameters it has and this UI can tell the Teensy when to change them.
9/∞