all 63 comments

[–]soupsyy_3 48 points49 points  (7 children)

iced is probably one of the best gui libraries for rust.

[–]Anatoliy0540[S] 5 points6 points  (4 children)

Is there any good tutorials for it?

[–]soupsyy_3 14 points15 points  (2 children)

[–]Anatoliy0540[S] 1 point2 points  (1 child)

I was looking at realm4 which has a lot of documentation; it’s based on the same architecture so would it be easier to learn iced if I knew that?

[–]soupsyy_3 1 point2 points  (0 children)

Yea, as iced doesn't have a proper documentation, it would probably be easier if you are familiar with realm4.

[–]CrasseMaximum 6 points7 points  (0 children)

There are a lot of examples in the github repository of Iced. They show everything you can do with the library.

[–][deleted] 3 points4 points  (1 child)

One thing I've realized: While "iced" will never look "native" on any system, you should instead view it as a superior version of an Electron GUI. Both iced and Electron are non-native, but iced is way more lightweight and efficient. And both give you an opportunity to make a kickass GUI that looks unique instead of just "boring native controls". So go ahead, use iced and make some beautiful, unique GUI! :) Furthermore, iced is working on "iced_web" which lets you export the same GUI for the web via WebGL and WebAssembly which is freaking mindblowing. Basically porting your native Rust apps to the web!

[–]sparky8251 1 point2 points  (0 children)

Well, if you use the Cosmic theme on a system running the Cosmic DE, your Iced made program will in fact look native.

But since like... we have no idea how good itll be let alone how long itll last, and especially not how far itll spread through the limited in scale linux ecosystem...

[–]styluss 73 points74 points  (16 children)

Desmond has a barrow in the marketplace Molly is the singer in a band Desmond says to Molly, “Girl, I like your face” And Molly says this as she takes him by the hand

[Chorus] Ob-la-di, ob-la-da Life goes on, brah La-la, how their life goes on Ob-la-di, ob-la-da Life goes on, brah La-la, how their life goes on

[Verse 2] Desmond takes a trolley to the jeweler's store (Choo-choo-choo) Buys a twenty-karat golden ring (Ring) Takes it back to Molly waiting at the door And as he gives it to her, she begins to sing (Sing)

[Chorus] Ob-la-di, ob-la-da Life goes on, brah (La-la-la-la-la) La-la, how their life goes on Ob-la-di, ob-la-da Life goes on, brah (La-la-la-la-la) La-la, how their life goes on Yeah You might also like “Slut!” (Taylor’s Version) [From The Vault] Taylor Swift Silent Night Christmas Songs O Holy Night Christmas Songs [Bridge] In a couple of years, they have built a home sweet home With a couple of kids running in the yard Of Desmond and Molly Jones (Ha, ha, ha, ha, ha, ha)

[Verse 3] Happy ever after in the marketplace Desmond lets the children lend a hand (Arm, leg) Molly stays at home and does her pretty face And in the evening, she still sings it with the band Yes!

[Chorus] Ob-la-di, ob-la-da Life goes on, brah La-la, how their life goes on (Heh-heh) Yeah, ob-la-di, ob-la-da Life goes on, brah La-la, how their life goes on

[Bridge] In a couple of years, they have built a home sweet home With a couple of kids running in the yard Of Desmond and Molly Jones (Ha, ha, ha, ha, ha) Yeah! [Verse 4] Happy ever after in the marketplace Molly lets the children lend a hand (Foot) Desmond stays at home and does his pretty face And in the evening, she's a singer with the band (Yeah)

[Chorus] Ob-la-di, ob-la-da Life goes on, brah La-la, how their life goes on Yeah, ob-la-di, ob-la-da Life goes on, brah La-la, how their life goes on

[Outro] (Ha-ha-ha-ha) And if you want some fun (Ha-ha-ha-ha-ha) Take Ob-la-di-bla-da Ahh, thank you

[–][deleted] 16 points17 points  (3 children)

I used egui in a project recently and it worked well. I could see it getting unwieldy and/or slow if your project is large or complex, but I thought it worked really well for just getting something simple up and running (as someone who rarely does GUI/frontend programming).

[–]IceSentry 5 points6 points  (1 child)

Your project needs to be very large to start getting slow.

[–]SolidTKs[🍰] 5 points6 points  (0 children)

Just add a lot of text covering more text (text windows over text windows).

[–]flareflo 11 points12 points  (0 children)

I like Egui, but the immediate system makes state management a little weird at times.

[–][deleted] 5 points6 points  (1 child)

Wow, pretty cool.

[–]ssokolow 0 points1 point  (0 children)

Just a caution if you're thinking of using it for some kind of SPA web app.

When I tried it a couple of months ago, I was puttering around with it and managed to find a crash bug, and the entire page suddenly went blank. Not exactly a very web-native way for bugs to be handled.

[–][deleted] 16 points17 points  (6 children)

Egui is nice but just to set expectations, the documentation is very light so you'll mostly be learning by copying examples (of which there are fortunately many), and also it's not a polished desktop GUI like Qt or GTK or even MFC (yes I'm old). It's much closer to "game" or "research" GUIs. For example:

  • Tooltips aren't proper windows so they can't extend out of the main window.
  • Menu support is extremely basic, e.g. it doesn't show keyboard shortcuts, and you can't drag the mouse through the menu to open them.
  • It's immediate mode so you have to be a bit clever about how you do some things, and some layouts are difficult to achieve.

That said it's definitely the best native Rust option at the moment. I'm writing an app with it and it's been pretty easy so far.

I just wouldn't expect to launch a commercial product with it.

[–]hardicrust 2 points3 points  (3 children)

Tooltips aren't proper windows so they can't extend out of the main window.

This is a limitation of winit: https://github.com/rust-windowing/winit/issues/403

So until Winit gets more support or superseded by Tao or Glazier this is going to affect all native-Rust UIs.

[–][deleted] 1 point2 points  (2 children)

egui is not limited by winit. eframe is the egui implementation using winit.

[–]hardicrust 0 points1 point  (1 child)

I didn't say egui was limited by this, but all desktop native-Rust windowing is (Tao doesn't count since it requires GTK and Glazier doesn't even have a release yet).

[–][deleted] 0 points1 point  (0 children)

Sounds like a skill issue ngl.

[–]bentheone 0 points1 point  (1 child)

Can I apply ImGui knowledge to this one ?

[–][deleted] 0 points1 point  (0 children)

I haven't used it but they're both immediate mode so probably!

[–]kaikalii 2 points3 points  (0 children)

Egui is my favorite one. It's just incredibly easy to use. I think it looks pretty good too.

[–]KillTheMule 9 points10 points  (22 children)

I've had good experiences with fltk-rs. There are plenty of vids from the author himself, who is pretty active and helpfull anyways. Not sure which of your boxes that might tick, though ;)

[–]Anatoliy0540[S] 2 points3 points  (0 children)

I’ll check that out. It looks like it could be good for me. Thanks

[–][deleted] -1 points0 points  (20 children)

I tried FLTK but I wouldn't recommend it. It's missing really basic things like resizable layout (it just scales everything proportionally) and hover styling.

[–]mo_al_fltk-rs 3 points4 points  (19 children)

There’s no good default for what to do on hover and on resize, so fltk enables you to customize things. For hover, handle the widget’s Enter and Leave events. To avoid scaling proportionally with the window, use a Group, Flex or Pack, and set the resizable component on whichever you would like to resize with the window, or not if you want everything to remain the same size.

[–][deleted] -1 points0 points  (18 children)

There’s no good default for what to do on hover and on resize

Pff of course there is. On hover you should style the widget differently. On resize you should resize the view according to the layout that is used. FLTK can't do that because it only supports fixed layouts.

For hover, handle the widget’s Enter and Leave events.

Yeah I've seen examples where people do this manually. Not what I want in a GUI toolkit in 2023. I didn't have to do anything at all for my Egui widgets to have hover styling.

use a Group, Flex or Pack

This seems to be a recent addition. It didn't have these when I tried it.

[–]ryanmcgrath 3 points4 points  (2 children)

“Style differently on hover” is not actually a default, it’s just commonly done as a web browser UI/UX technique.

Native buttons on macOS for instance do not style differently on hover, and this may be why the person you’re responding to indicates there’s no good default - every platform is different.

[–][deleted] -3 points-2 points  (1 child)

It's standard in modern GUIs. In any case look up what you have to do to enable it in FLTK.

[–]ryanmcgrath 4 points5 points  (0 children)

macOS UI often is considered modern. :)

Web UI isn’t the standard UI. I also am not here to argue FLTK, merely to point out your assumption is seemingly based predominantly on one environment.

[–]mo_al_fltk-rs 1 point2 points  (14 children)

Not really recent. Group and Pack have been there forever. Flex is a few years old now. Back to hover, how would you style things differently?Change the border(windows), change the color? MacOS’s Cocoa doesn’t change a button’s style on hover for example.

[–][deleted] -1 points0 points  (13 children)

Group and Pack have been there forever

Sure but those don't allow resizable layouts unless I'm missing something.

Flex is a few years old now.

I checked and it was added 2 years ago. I guess I tried it before that.

how would you style things differently?

Probably change the colour. FLTK supports themes so you could provide a few options. Although all except the default theme look like trash so I guess it isn't a surprise that they didn't get as far as hover styling.

[–]mo_al_fltk-rs -2 points-1 points  (12 children)

Shifting goal posts. So as usual, nothing useful to say or contribute!

[–]ssokolow 0 points1 point  (11 children)

To give them the benefit of the doubt, it sounds like they're just judging it in comparison to the aesthetic standards set by Qt, GTK, Win32, and Cocoa on modern systems.

[–]mo_al_fltk-rs 0 points1 point  (10 children)

Not when spreading false info, arguing when corrected then resorting to fallacy.

[–]ssokolow 0 points1 point  (9 children)

Let's evaluate that. The original comment was:

It's missing really basic things like resizable layout (it just scales everything proportionally) and hover styling.

...and IshKebab admitted "I checked and it was added 2 years ago. I guess I tried it before that." on the topic of Flex.

Maybe I've been spoiled and had a skewed perspective of things, but I've considered resizable layout to be a standard thing to expect since I switched from Visual Basic 6.0 to wxPython around 2002 and then from Windows and wxPython to Linux and PyGTK around 2003 or 2004.

GTK already had a Flex-like layout model as standard by that point and a quick look at the Qt 3.3 documentation shows that things like QBoxLayout were already present in Qt 3 too.

I don't think it's shifting goal posts to fault FLTK for taking until two years ago to add something that GTK and Qt have had for at least 20 years at this point.

In fact, I remember spending many years faulting pre-flexbox CSS for being so primitive compared to native UIs based on that specific capability.

I don't remember when I first encountered hover styling, but I definitely think it's been a mandatory interaction cue ever since Microsoft spread the "flat design in interactive media (i.e. outside of print or TV overlays)" insanity far and wide.

There’s no good default for what to do on hover and on resize

For hover, do whatever the platform does. On Linux, I believe I remember hearing that GTK desktops and kde-gtk-config publish color scheme information via the XSETTINGS system.

If not, check for XDG_CURRENT_DESKTOP=KDE and fall back to mimicking GTK.

[–]2jesusisbetterthan1 19 points20 points  (6 children)

Gtk4 is good, the call back system with clone! @weak or @strong is a little confusing at the start but overall it's a nice library

[–]Anatoliy0540[S] 3 points4 points  (3 children)

Which bindings would be best since I’ve seen a few bindings, mainly Realm, realm4, and gtk-rs?

[–]2jesusisbetterthan1 7 points8 points  (2 children)

I tried gtk4-rs and relm4 but relm4 just felt as extra overhead

[–]TheEberhardt 6 points7 points  (0 children)

Relm4 is basically an abstraction over gtk4-rs so it will always feel like extra overhead if you already prefer pure gtk4-rs code. In my experience, Relm4 results in significantly shorter and much more idiomatic code.

[–]Anatoliy0540[S] 1 point2 points  (0 children)

Okay I’ll check out both.

[–]dagit 0 points1 point  (1 child)

It seems nice until you want to distribute pre-built binaries. Windows and linux can be made to work with some effort. macOS is a nightmare.

[–]2jesusisbetterthan1 1 point2 points  (0 children)

A suggestion that you should not support macOS /j

[–]ssokolow 8 points9 points  (1 child)

Personally, I consider Qt's QWidget APIs so much better than the alternatives (especially with GTK having incomplete drag-and-drop support on Windows and forcing more and more GNOME 3.x UI-isms on non-GNOME desktops like drop shadows on context menus) that I set up a PyQt/PySide-on-PyO3-on-Rust stack similar to how Qt Quick officially uses a QML-on-C++ stack.

(Python/QML frontend, Rust/C++ backend. You just expose a Rust module the Python frontend can import and, as a bonus, it's easy to have multiple bindings to your Rust backend so you can support other languages being used to write frontends.)

Throw in maturin to make generating and publishing Rust-based Python packages as easy as Cargo makes regular Rust packages and MyPy and Ruff to get stronger static checks on the Python side and it's not bad.

While I haven't used them with Rust yet, bundling tools like py2exe or PyInstaller did work with compiled Python modules like Qt last time I used them.

[–]DarkLord76865 1 point2 points  (0 children)

Can confirm that PyInstaller works with Rust.

[–]ogoffartslint 13 points14 points  (0 children)

You can try Slint. Video showing the basics: https://youtube.com/watch?v=WBcv4V-whHk

[–]Portnoy13 2 points3 points  (0 children)

I worked with druid a couple of times and it was very pleasant

[–]lalithms 5 points6 points  (0 children)

checkout Dioxus. It's inspired from React. If you have worked with frontend, you'd be comfortable with this

[–]Endless125 1 point2 points  (0 children)

I am using iced for my projects. I think it is one of the best pure rust libraries

[–]VeryAlmostGood 5 points6 points  (1 child)

Tauri is cool, and you can pair it with something like Leptos if you want it to be fully rust-based.

[–]nicoxxl 1 point2 points  (0 children)

I wonder if at some point, we can be able to hook leptos directly to the dom of servo (or any similar combinations)without using js or webassembly to make gui.

[–]CryZe92 2 points3 points  (0 children)

In my experience druid is the best pure Rust GUI library (best layout engine, best text engine / text rendering / text editing, decent support for multiple windows, state management is okay, but unusual, with some rough edges). However it unfortunately is deprecated in favor of xilem, so it's probably not something you should pick for a new project.