Skip to content

ui_slint#732

Merged
ilius merged 14 commits into
ilius:masterfrom
glowinthedark:ui_slint
Jul 6, 2026
Merged

ui_slint#732
ilius merged 14 commits into
ilius:masterfrom
glowinthedark:ui_slint

Conversation

@glowinthedark

@glowinthedark glowinthedark commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Maybe this is too much, dunno, but felt like playing with this new rust-based UI toolkit (still in BETA) and thought that the best way would be doing something actually useful rather than hello-world stuff. Up to you to decide how useful this is, or if it's another toolkit to maintain with all the pains that come with it. I will fully understand if you decide to reject the PR - totally fine with me.

In any case, here it is:

Slint UI for PyGlossary

default (system) theme;
image

cupertino theme (light, can be dark too, selectable under Options > Theme)
image

Features

  • biggest ONE 😆 based on BETA slint toolkit, currently 1.17.0b2
  • feature parity (?) with tkinter
  • smaller size final build than tkiner, qt, wx, gtk

Gotchas and WTFs

  • threading and object allocations in slint are strict and passing slint objects between threads causes panics 💥 which seem to be triggerred by gc deallocating objects when the thresholds are triggerred; this was solved by preventing any sling objects to be passed to threads and having to directly use gc methods.. -- yes, this is ugly, and apparently, no nicer way exists or at least none of the 🤖 assistants could find a cleaner solution; this alone could be a sufficient reason for you to not want this in master. Having said that, the current code works without panicking and was tested to work on mac/windows/linux both when running from source and when running from nuitka binaries (some type of panics were only occurring with nuitka binaries but not when running from sources). slint is not a per se a python 'native' widget toolkit; it's rust-based, and python is among the other (~2nd hand) options as opposed to native rust.

Limitations and workarounds

  • slint does not have it's own GUI file picker - they justify it by the need to keep the framework 'lean' and avoid bloat :D - the workaround that is applied is to delegate to whatever is available in the OS: for mac it's using osascript which can show a file picker, for windows WFP via powershell and on linux zenity/kdialog, all wrapped in pyglossary.ui.ui_slint.utils.pickOpenFile(). Surprisingly, this works seamlessly and shows native pickers on all three OS's.

  • github actions are included for building slint nuitka binaries for mac and windows; was thinking to maybe add another one for building linux AppImages but that will probably be in another scope, if ever. Before I always assumed that all linux users were able to compile anything from source, but keep discovering real people who use linux desktops and don't know how to install a .deb 😆

Overall I'd say slint looks promising with its flutter-style declarative syntax, but still too new and still far from the level of polish, robustness and googleability of pyqt, pygtk or even tkinter. The ball is on your side now, and I assume you know better what to do with this :D

@ilius

ilius commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Not bad at all.
But still not as good as our Tk, Wx or Qt UI for Windows or Mac.
So I'm just not sure I want to include the executable releases just yet.
But thanks or the effort.

BTW it doesn't follow system theme on Linux.
My desktop theme is dark, but slint's default theme is light.
And none of selectable themes are dark.

@ilius

ilius commented Jul 5, 2026

Copy link
Copy Markdown
Owner

I'm gonna add an env var for changing default UI.

- add explicit Light/Dark variation to Settings > Theme
@glowinthedark

Copy link
Copy Markdown
Contributor Author

Dark/light detection appears to work smoothly on mac and changes on the fly when the system setting is changed; on windows didn't test specifically the dark/light, and on linux according to searches system dark mode might not be detected or have issues depending on which desktop env is used. And also this: https://slint.dev/blog/default-native-style-change

🌞
image

🌑
image

I've updated the Theme dropdown to include explicit Dark/Light variations specifically for OS's and DE's where dark detection does not work, so now it allows explicitly selecting Light/Dark even if it's not the current OS preference.

image

There is also https://pypi.org/project/darkdetect/ but it's an additional dependency and a crutch which supposedly fixes something that the OS + UI toolkit should do ootb, I guess better avoid it.

@glowinthedark

Copy link
Copy Markdown
Contributor Author

@ilius

ilius commented Jul 5, 2026

Copy link
Copy Markdown
Owner

I've updated the Theme dropdown to include explicit Dark/Light variations

Did you push it?

@glowinthedark

glowinthedark commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

I've updated the Theme dropdown to include explicit Dark/Light variations

Did you push it?

Very good question! I did the update, but didn't do the push 🤦 until now

double-checked it's included now: https://github.com/glowinthedark/pyglossary/blob/26e54e673a03b12cd8e0deb7986fe372edc5faa3/pyglossary/ui/ui_slint/utils.py#L45

@ilius

ilius commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Thanks.

Just a small bug: the theme drop-down does not exceed the window (it's not a real "menu"), and the window's default size is too small for this "menu".

Screenshot at 2026-07-06 01-01-43

@ilius

ilius commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Actually if the drop-down menu can not exceed the window, and we can't calculate its size, it's probably better to replace the theme drop-down with a list of radio buttons (a group of round checkboxes that only one can be checked). Like QRadioButton

fusion-radiobutton

Improvements for later:

  • All dialogs / windows should be closed with Escape key.
  • If possible, all windows should be opened in the center of their parent, or the center of screen (I know Wayland does not allow that, nor does GTK-4).
  • The "Options" dialog could be changed to a menu (like QOptionButton menu) unless it's going to have the problem

- dismiss with Escape for dialogs
- themes rendered as list (not combo)
@glowinthedark

glowinthedark commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author
  • Options is a combo
  • Esc to dismiss dialogs
  • themes as list

@ilius

ilius commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Thanks.
The selected theme item does not look selected though.
When you click on one, and move you mouse, you can't tell which one is selected.

@glowinthedark

glowinthedark commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. The selected theme item does not look selected though. When you click on one, and move you mouse, you can't tell which one is selected.

It shows a colored sidebar on the left when selected. The color might not be contrast enough to be well visible in both light and dark - will investigate and adjust.

Update

Turns out the sidebar color indicator depends on the specific theme currently selected, for example for cupertino-dark it is visually prominent

image

but for the light mode the (light gray) bar to the left of Cupertino Light is almost invisible.
image

Will fiddle more with it to find out which standard Palette colors can be used and avoid hardcoding actual colors.

- make Options focusable with Tab key navigation, and items selectable with keyboard up/down + Enter
- Escape to discard
@glowinthedark

glowinthedark commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Now themes dialog looks more convincing with handmade "radiobuttons" (slint doesn't have a native radio button widget) - I like it better this way; also enabled item selection with up/down keys (previously the items were unfocusable); the handmade UpComboBox was also not handling focus before, now it does so the UI can be navigated with keys only.
image

@glowinthedark

glowinthedark commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

hm, actually slint does have a RadioGroup widget - I'll use that one instead.

Also here in the demo: https://slintpad.com/?load_demo=examples/gallery/gallery.slint

@glowinthedark

Copy link
Copy Markdown
Contributor Author

redone with native RadioGroup/RadioButton; looks about the same as before:
image

@ilius

ilius commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Nice.

@ilius
ilius merged commit fd88e23 into ilius:master Jul 6, 2026
9 checks passed
@ilius

ilius commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Next fixes/improvements:

  • Set window icon (for each window, or set default window icon)
  • Change progress bar to show the text on top of it, so that the size of the bar does not change as text size changes.
  • About tab to be like other UIs

@glowinthedark

glowinthedark commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@ilius

Set window icon (for each window, or set default window icon)

for the nuitka builds the icon is already set; it's only when running from sources that there is no icon, I think that's the case for all UI flavours, tk, gtk, qt, wx, no?

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 this pull request may close these issues.

2 participants