Live data from Hacker News

GUI development with Rust and GTK 4

gtk-rs.org

51–60 of 172 posts

Re: GUI development with Rust and GTK 4

#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

Re: GUI development with Rust and GTK 4

#52
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?

I guess we have come the full circle.

Speaking from a mobile dev's perspective, the native UI design in 2010s was done by XML based files (storybooks in iOS/macOS, XML layout files in Android) and native code would "connect" with the XML files in various ways. Now the development is moving towards declarative approach using frameworks such as SwiftUI and Compose.

This builder pattern resembles quite a bit of how you would declare UI in SwiftUI and Compose.

Re: GUI development with Rust and GTK 4

#53
post #10
post #7

Earlier quoted context omitted.

There are plenty of situations where GTK might be better than Slint, but not so overwhelmingly that I'd call it only for toy apps.

While you can create one on your own, any lib that doesn't have a tree widget isn't ready for primetime IMO. Obviously others may have a different opinion. Also, I don't believe there is any way to embed a webview at this point which is often necessary to embed things like charts or other widgets you don't want to create on your own.

Also, tableview/datagrid, complete with support for sorting and reordering items and columns.

It’s shockingly difficult to find newer UI frameworks with this, even though it’s one of the most important desktop UI widgets for a lot of use cases. Win32, Cocoa, GTK, and Qt Widgets have it though, and that’s part of why those toolkits continue to get used.

Re: GUI development with Rust and GTK 4

#54

Earlier quoted context omitted.

The apostrophe isn’t superfluous. ‘Static in this context refers to static lifetime. Lifetimes have absolutely 0 impact on runtime.

How would you get a static lifetime without a static object?

Unrelated to the above convo, but: An owned object can be bound by a static lifetime, for example. Eg, `fn foo(t: T){}\n foo(String::new());`

Re: GUI development with Rust and GTK 4

#55
post #14

Earlier quoted context omitted.

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…

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,…

> Edit: dropping the demo link here for people to poke around. I'm curious what people use that is missing, and what people find unsuited to commercial use.

As I alluded in my other comment, theming is possible but it's really limited if you expect anything close to what you'd typically expect. You can put borders and colors on frames, but it's pretty limited. For example, if you want to have a border with different colors on each edge, or a border on just one edge, you can't do that by default. I had to make a custom frame object that is a frame in a frame to make different sized borders, but it's still a single color.

I created a mockup in PowerPoint (my go to design app... I'm not a designer, but it has everything I need and I know how to use it), and I had a lot of difficulty getting the egui design to match my PP design, because PP actually has a fairly advanced styling engine with a ton of options, and I took advantage of those. So when I go to egui, the default theme didn't support the kinds of design elements I wanted to show.

But, like I said, you can make these things yourself with the egui building blocks without much trouble.

The other thing I found a little frustrating was chromeless windows. There's an example of this, but it didn't seem well supported. The idea is that when you turn off chrome, you can't resize or close your app. So then you have to add all that functionality back. There's a demo that shows this, but it seemed like a pain at the time to integrate into my app. I gave hoping it would be fixed soon, so I will revisit.

Re: GUI development with Rust and GTK 4

#56
post #39

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,…

I need very flexible charting. While egui has some basic stuff builtin, I need something closer to what imgui-charts has (which makes imgui-rs a candidate for me, but probably not egui). A webview would also work as a fallback with a JS charting lib, but egui can't do that either.

Imgui-rs looks really good, thanks! Imgui does say it can output raw vertex buffers, so you could probably put imgui stuff in an egui gl frame and reskin egui to match the looks.

I've only kicked the wheels a bit on egui, but for plotting signals it seemed more than adequate. Its histograms looked fine too. The only thing I saw missing was 3d plotting and heat maps.

Re: GUI development with Rust and GTK 4

#57
What about making it easy to import Rust business logic into C# / Swift / whatever GUI language you're using?

I get the value of 100% (or 50% or 80%) implementing the UI in Rust; especially for tools that won't benefit from a native UI, or tools that only need light integration into platform-specific UI features.

I've also shipped a desktop product that had a 100% native UI and a cross-platform codebase. Today, implementing that cross-platform codebase in Rust and then importing it into native C# and Swift codebases for the Mac and Windows variants would be ideal.

Re: GUI development with Rust and GTK 4

#58
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?

This example shows off the builder style, but since gtk-rs is built on top of GTK, .ui XML files are also supported. You can edit .ui files using the legacy Glade editor (with a conversion script), the newer (but incomplete) Cambalache project, or by hand (it's not that hard and this seems to be the preferred way nowadays)

https://gtk-rs.org/gtk4-rs/stable/latest/book/composite_temp...

Re: GUI development with Rust and GTK 4

#59
post #40

At this rate programming languages will reinvent GUI builders from Delphi/Lazarus in 2050

I still find it quite sad that the pinnacle of GUI programming tools was reached over 20 years ago, when Delphi 6 was released, and we've been going more or less downhill ever since.

I see it differently: UI needs have gotten more complex. Like how we used to have web sites that said "best viewed in 800x600 in Netscape Navigator" we rarely design one size fits all UIs any more like we did in Delphi.
Post reply on HN