Live data from Hacker News

GUI development with Rust and GTK 4

gtk-rs.org

41–50 of 172 posts

Re: GUI development with Rust and GTK 4

#41
post #35

Earlier quoted context omitted.

I mean no offense to the egui people because they have done amazing work, but it isn't that it isn't native, it is that it doesn't look good enough to ship something with it (other than a science/medical/gaming UI perhaps, but certainly not a business app). Gtk won't look native either on anything but Linux...at all, but at least is very professional looking in its default theme. Obviously what looks "good enough" is…

You can skin it fully though. I have an app that looks nothing like the default theme. Customize it to your taste. Note: I did have to implement some missing features for my purpose, so when I say “fully” I mean I had to spend a couple hours putting the features I wanted together. But in the end, it was a great result. Maybe this work should be turned into a PR, I dunno.

Good points. It also matures quite quickly and has lots of attention.

Re: GUI development with Rust and GTK 4

#43
post #4

AFAIK, for better or worse, this is the only UI crate (other than HTML-like UI using something like Tauri) that provides a full set of widgets/capabilities on Rust. Every other UI lib is incomplete in some way or falls short for anything other than a toy or specialty type app in my experience. UPDATE: Things I have my eye on as they mature: Slint, egui, and iced. I'm especially watching iced as Pop_os is using it for…

In my limited experience, I would add cacao for MacOS to that list.

I believe that having a common language but using native widgets is the sweet spot for many cross platform projects and teams.

Re: GUI development with Rust and GTK 4

#44
post #4

AFAIK, for better or worse, this is the only UI crate (other than HTML-like UI using something like Tauri) that provides a full set of widgets/capabilities on Rust. Every other UI lib is incomplete in some way or falls short for anything other than a toy or specialty type app in my experience. UPDATE: Things I have my eye on as they mature: Slint, egui, and iced. I'm especially watching iced as Pop_os is using it for…

[deleted]

Re: GUI development with Rust and GTK 4

#46
post #27

I wondered how Rust would tackle the problem of creating a GUI without C++/Java style inheritance and now I see the answer: you must explicitly compose all "inherited" traits in your subclass. "Unfortunately, nobody found yet a good way to do that. Which is why, as of today, subclassing of GObjects in Rust requires to mention all ancestors and interfaces ..."

You can create UIs entirely out of composition. It's not even that hard, or that foreign per se. The problem you see there is a mismatch between Rust and GTK specifically, not GUIs in general. Of course, all the major GUIs are inheritance based, but I count that as less evidence than I might under other circumstances because GUI toolkits are multi-decade endeavors at the top end, and all the viable ones date to when…

React is the most interesting GUI approach to me in this regard, as while you can use inheritance if you use the class-based component approach, functional components are, well, functions and can be built by rules of composition. I tend to do a lot of UI in the form of "component with a dozen parameters that almost nobody wants to use every day" that is wrapped by "specialization of the general component that has a few parameters and then uses the general component by wiring those parameters and some logic together."

Any type of "hot patching" is a bit more difficult (I can't easily just reach down a component's tree and mutate it from outside, not unless I've pre-wired the component to allow for that, and the semi-artificial limitation of the use of the tree model as a single `children` property means that such odd wiring gets weird fast if I want to get fancy). But it's a perfectly serviceable UI toolkit framework that is free of requiring inheritance.

ETA: deferring to nu11ptr's taxonomy, React is not a widget toolkit by any means by itself. I find https://react.semantic-ui.com to be perfectly serviceable in that regard as a base, easy-to-modify widget toolkit.

Re: GUI development with Rust and GTK 4

#47
post #41

Earlier quoted context omitted.

You can skin it fully though. I have an app that looks nothing like the default theme. Customize it to your taste. Note: I did have to implement some missing features for my purpose, so when I say “fully” I mean I had to spend a couple hours putting the features I wanted together. But in the end, it was a great result. Maybe this work should be turned into a PR, I dunno.

Good points. It also matures quite quickly and has lots of attention.

I still think the webview thing will be a long time coming if that is something you absolutely need. Best bet is probably something that renders the output of a web engine to gl to stuff in an eguingl window.

I've used such horribly themed business guis that my expectations are probably very skewed. If there are buttons and text windows, and neither of them move when I try to select them, I'll survive. My only explanation is kickbacks to the person that selected their purchase. The worst is when the text entry fields silently sanitize things sent to the server so you don't actually know what went into the database. Well, I guess the worst is that it didn't sanitize the entry at all and some of the characters had special meaning to the ancient backend...

Re: GUI development with Rust and GTK 4

#48
post #9

Rust GTK4 "hello world" app, as a downloadable project, demonstrating the builder pattern: https://github.com/SixArm/rust-guideposts/blob/main/projects...

Honestly this looks like programming style from 90s. Why not design UIs in an editor that saves layout to XML?

> Why not design UIs in an editor that saves layout to XML?

Not sure if you are being sarcastic or not, but nothing is more 90s than XML based layout descriptions. Mozilla XUL (recently retired) comes to mind.

Re: GUI development with Rust and GTK 4

#49
post #48

Earlier quoted context omitted.

Honestly this looks like programming style from 90s. Why not design UIs in an editor that saves layout to XML?

> Why not design UIs in an editor that saves layout to XML? Not sure if you are being sarcastic or not, but nothing is more 90s than XML based layout descriptions. Mozilla XUL (recently retired) comes to mind.

XUL needs to be resurrected (reimplemented)

Re: GUI development with Rust and GTK 4

#50
post #9

Rust GTK4 "hello world" app, as a downloadable project, demonstrating the builder pattern: https://github.com/SixArm/rust-guideposts/blob/main/projects...

Honestly this looks like programming style from 90s. Why not design UIs in an editor that saves layout to XML?

> Why not design UIs in an editor that saves layout to XML?

It's funny because that's my personal nightmare. I'm a JS to Rust developer so I'm biased but the likes of React and Svelte have spoiled me with the ease with which you can integrate reactive components into a UI in a way that you simply can't when you're using a separate XML file.

I agree that the example given looks old-school but Rust has a wonderful macro system, I can imagine building a really slick compose method with macros that generates this kind of code underneath.

Post reply on HN