Me and my teammates want to start a Python code base involving custom graphical user interface (GUI) applications that can be easily deployed internally and even distributed externally to customers. I expected this task to be trivial in 2020, but I seem to hit dead-ends/major issues every path that I explore. So after spending countless hours in research and unsuccessful problem solving, I decided to summarize my goal and ask the community. I am sure the solution would benefit many.
NOTE: I am not seeking "recommendations" but factual solutions that are known (based on experience) to meet the specific requirements below.
Goal
Find a GUI toolkit solution for Python 3 with the following requirements:
License: Free, for development and light commercial distribution.
Portability: Portable and easy to deploy on Windows 10, but also Mac OS X and Raspberry Pi (and maybe some mobile experiments).
2D Graphics: It must offer a way to present and update 2D graphics in semi-realtime (like updating the data of a matplotlib FigureCanvas multiple times per second).
UI Design: A visual designer application must be available to design and update the GUI interface definition (in a text file that can be loaded by the Python code).
UI Styling: It must offer an easy way to completely restyle the visual elements, ideally in a CSS-like manner (like adjusting the corner radius of buttons, colors, shadows or create a custom theme).
Attempts explored so far
Attempt 1: tkinter.ttk (TCL/Tk engine)
[OK] Free
[OK] Already part of Python 3 distribution
[OK] FigureCanvasTkAgg
[OK] pygubu-designer application, along with pygubu.Builder loader.
[NOT OK] While ttk offers some color styling (ttk creating and using a custom theme, Python Tkinter custom themes), and predefined themes, I have not found any way to restyle the controls (i.e. adjust the roundness and shading of a button). See below.
Styling problems with tkinter.ttk
I can mimic the element structure of the 'clam' ttk theme button for instance (Create custom ttk style same as 'clam' ttk Theme (button widget specific)), but not reproduce the actual look/rendering of the button in python (corner roundness, gradient, etc.).
Using bitmaps or drawing raw shapes on a canvas are not acceptable solutions (Rounded button tkinter python)
EDIT: By inspecting the source code of some nice ttk themes, it reveals that shading and round button effects are all performed using bitmaps, which greatly increase the complexity of styling. BTW, the TCL script of the theme is actually interpreted (live) behind the Python tkinter module.
Attempt 2: PyGOjbect (GTK 3 engine)
[OK] Free
[NOT OK] I have not found a way to deploy on Windows 10 easily. See below.
[OK] FigureCanvasGTK3Agg
[OK] Glade (designer application saving .glade XML files) and Gtk.Builder (layout loader in Python).
[OK] Gtk.CssProvider allows full customization using CSS-Like syntax.
Deployment problems with PyGObject on Windows 10
- I was successfully able to install PyGObject (GTK3) on Windows using MSYS2 (Where can I download precompiled GTK+ 3 binaries or windows installer?), but it runs outside of a normal conda/pip installation.
- "The PyGObject eco-system is not commercial-ready on Windows" (Shipping PyGObject/GTK+ app on Windows with MingW)
- "install MSYS2" (How to build a GTK+3 program on Windows without MSYS2?)
- I have not tried vcpkg yet, but I read "The vcpkg packaging is not maintained or supported by the GTK team" (https://www.gtk.org/docs/installations/windows/#using-gtk-from-vcpkg-packages).
Attempt 3: wxPython (wxWidgets engine)
- [OK] Free
- [OK] Standard Python multi-platform package
- [OK] FigureCanvasWxAgg
- [WARN] something like wxGlade with wxGlue could work, but not widely adopted/maintained
- [NOT OK] wxWidgets seems to focus on "native" controls (Python - Custom styling in wxPython)
Attempt 4: PySide2 (Qt engine)
[NOT OK] Not free. Qt commercial license is $4k/developer if funding >$250k.
[OK] Can be deployed on Windows 10 and many other platforms
[OK] FigureCanvasQTAgg
[OK] Qt-Designer application and Python QUiLoader
[OK] Qt Style Sheets (QSS)
Attempt 5: Web Rendering Engine
[OK] I could explore many free options to create desktop-like applications using web technologies, such as REMI, PyWebView, eel, Flexx, Dash, etc.
[OK] These options are generally standard Python packages
[WARN] However to update a matplotlib plot usually involves refreshing an IMG source bitmap, which might not be optimal for high refresh rates
[WARN] I could probably use a standard HTML/Web visual designer, but would need adaptation to Python module.
[OK] HTML output would support all common CSS styling options.
Concerns with web rendering engines
- I havent explored this option far enough yet.
- Maybe the matplotlib refresh issue could be overcome with a JS plotting alternative such as plot.ly.
- But I feel the level of complexity is increasing far beyond expectations. Is this my only option?
EDIT: Attempt 6: Kivy
- [OK] Free (MIT License)
- [OK] Standard Python multi-platform package, and buildozer to create application packages.
- [OK] FigureCanvasKivyAgg (
pip install kivy-garden
, thengarden install matplotlib
) - [NOT OK] kivy-designer is DEPRECATED and no alternative found.
- [OK] kv-lang style definition
Is there any elegant solution to this technical challenge, meeting all 5 requirements?
Thanks