Live data from Hacker News

GUI development with Rust and GTK 4

gtk-rs.org

131–140 of 172 posts

Re: GUI development with Rust and GTK 4

#131
post #118

Earlier quoted context omitted.

One argument I've heard for this model is that, by having the UI in a declarative language, the design team can update/experiment with the layout without having to understand the backing logic. I've only been on one team that actually subscribed to this model though.

I've heard this, but in practice it is hard to fully decouple the interface from the logic so experimentation with the front end usually involves work on the back end. Even simple changes like "we want to change this drop down to a set of radio buttons" ends up requiring changes on the back end most of the time.

I think good tooling support is a requirement for this to work; the one project I used this in (a Silverlight app) had first-class support for this. You could specify separate ViewModels for run time and design time, and the latter would just return static values that the designer could work against. I guess this would require some cursory understanding of C# syntax, but I think the ramp-up for adding/modifying a property would be minimal.

Re: GUI development with Rust and GTK 4

#132
post #74

Earlier quoted context omitted.

I really like XML a lot ; I've gotten large numbers of people to use XML & XSLT, where I work. XML is dated, and it is gross. Here's the two things the XML ecosystem nailed , which tie me to it: 1. A dedicated tree-based transformation language (XSL); and, 2. Axis-queries (Xpath). If I could Xpath all-the-things, I'd be a happier human. Although, I also feel like I should be able to SQL all-the-things, too. Maybe I'm…

XSLT is garbage tho.

XSLT the syntax leaves a bit to be desired. There's also a number of highly questionable default behaviors that are really unfortunate. OTOH, the concept of a term-rewriting tree-matching language is pretty great.

Re: GUI development with Rust and GTK 4

#133
post #51

Has anyone gotten GTK to compile on Windows without using MSYS? I would love to use pygobject with Python but the build chain and how to get it working is extremely confusing to me. Back in the days of gtk2, pygtk2 used to work wonderfully and compiled with MSVC

It's a hidden gem, but gvsbuild [1] has made it easier again these days - I just discovered it ~a year ago and it's beautiful :) [1] https://github.com/wingtk/gvsbuild

sweet! I wonder if that can somehow be integrated with pygobject

Re: GUI development with Rust and GTK 4

#134

Earlier quoted context omitted.

Native look and feel is vastly overrated imo. Delphi and before it borland builder made for great UIs despite not looking native. To the point that when I came across that widget set, I knew I was in for a good UX. Still many bespoke interfaces, like at a brakes repair or small lumber yard chain use delphi and it works just fine. As for the webview, thats a thing, but if you will have web access, you can target wasm,…

Since you link to the the web demo, I want to caution people: yes, egui can run on the web, but treat that as a demo only done over the web for the convenience of not having to download and run it natively. If you’re making something, do not use egui if you want to actively target the web, because it’s really bad there in fundamentally unfixable ways (given egui’s architecture). Egui is quite compelling on non-web pl…

I didn't have any problems with fonts (I don't block Any), middle clicking opened in a new tab, egui supports context menus, just not the browsers (which is what I want from a webapp).

Re: GUI development with Rust and GTK 4

#135
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…

For me the litmus test is if it has a fully-featured listview or treeview, so you can do something like a file browser, a library app, or other kinds of data-heavy apps. Also important is that keyboard and mouse work as expected (tabbing, shift-selection, etc). Bonus if it supports the current "native" OS paradigms. E.g. on Mac: transparent sidebar, integrated titlebar, on Windows: MS office 2022 style simplified too…

[deleted]

Re: GUI development with Rust and GTK 4

#136
post #45

If you're like me and like pictures in your books: https://docs.gtk.org/gtk4/visual_index.html

This is a typical code snippet:

final class Gtk.Label : Gtk.Widget implements Gtk.Accessible, Gtk.Buildable, Gtk.ConstraintTarget { /* No available fields */ }

What language is that in?

Re: GUI development with Rust and GTK 4

#137
post #14

Earlier quoted context omitted.

I think egui is complete enough to use in real apps. Layout can be a bit weird, but I haven't found anything that's impossible. I might even prefer it for cross-platform apps since startup time is so slow for GTK on Windows.

The challenge with egui is the theme. It looks ok, but isn't good enough for a commercial business app for example. Also, I believe it lacks a webview, so if you are in a pinch the only thing you can do is create your own widgets without a way to cheat and embed some web content. I would agree for certain types of apps it may be "good enough" (science, gaming, medical perhaps...anything where the UI is secondary to t…

Have you seen emilk's own company, https://www.rerun.io/? All build on top of egui! Check out the webviewer on https://app.rerun.io/. It's all open source, https://github.com/rerun-io/rerun.

Re: GUI development with Rust and GTK 4

#138
Great! So, let's refactor that UI code out into a function. Something a beginner is very likely to do as that code becomes more complex.

Oops. The borrow checker is going to beat you over the head. And beginners aren't likely to understand that it isn't their fault.

Rust needs to figure out a way to do GUIs ergonomically without requiring closures.

Re: GUI development with Rust and GTK 4

#139
post #138

Great! So, let's refactor that UI code out into a function. Something a beginner is very likely to do as that code becomes more complex. Oops. The borrow checker is going to beat you over the head. And beginners aren't likely to understand that it isn't their fault . Rust needs to figure out a way to do GUIs ergonomically without requiring closures.

Which UI code specifically are you referring to and why would the borrow checker prevent you from factoring it out?

Re: GUI development with Rust and GTK 4

#140
post #138

Great! So, let's refactor that UI code out into a function. Something a beginner is very likely to do as that code becomes more complex. Oops. The borrow checker is going to beat you over the head. And beginners aren't likely to understand that it isn't their fault . Rust needs to figure out a way to do GUIs ergonomically without requiring closures.

Which UI code specifically are you referring to and why would the borrow checker prevent you from factoring it out?

Well, I think the one that stuck out was here: https://github.com/SixArm/rust-guideposts/blob/main/projects...

But here: https://github.com/gtk-rs/gtk4-rs/blob/master/examples/text_...

and here: https://github.com/gtk-rs/gtk4-rs/blob/master/examples/clock...

The moment some poor slob of a beginner tries to refactor any of those closures into a "normal" function, they're going to get beat over the head by the borrow checker.

Yes, I know why they're required in Rust. And it makes sense once you know Rust well. But a beginner isn't likely to understand why they can't refactor a closure into a function in Rust without a whole lot of clone().

Coding "examples" for Rust need to stop using that closure style--especially in "beginner" code.

Post reply on HN