What is the best GUI tool to use for Rust?

Oh, that looks nice. :slight_smile: The rendering is rather old-fassioned looking, but if you need a lightweight GUI that runs on desktop and android. :+1:


Maybe check out OrbTK. Looks rather promising:

Only supports Android through Cordova right now, which could be slower than native if you're super critical about the low overhead on Android.

1 Like

I'm a little surprised nobody has mentioned are we gui yet - if you want to see the variety of GUI options out there in rust, that's a fairly-often updated reference.
Personally, I contribute small time to druid, and while we're still in 0.X releases (and will probably be for years to come), I think you can write small applications reasonably well. There are a lot of caveats there though - and there are as well with most of the other Rust GUI toolkits.

7 Likes

WOuld orbtk support Android one day without Cordova?

Yeah, in the readme it says that native support is planned.

1 Like

I think fltk is retained mode, not immediate mode.

Another question is is it retained mode or immediate mode?

retained mode means it does not draw every frame per second if I am not mistaken?

Yes, it means that it only re-draws when something changes instead of drawing every frame.

I'm not positive, but it seems like it is probably retained mode. They say it has " a functional Reactive-like API", which seems to hint at that, and most immediate mode GUIs advertise themselves as such, so I think it's retained, but I'm not positive.

1 Like

So why not just do that, make your Rust program a web server, use the browser for all it's powerful GUI building features and HTTP and web sockets in between?
That has security implications.

Unless you take steps to prevent it, any process running on the machine could interact with that web server.

You seem to have added "That has security implications" to what I said when quoting me.

OK, fair enough.

Your desktop experience is already a mess of components communicating via the X Windows protocol, or dbus, or whatever. None of which is secured. For which the same could be said "any process running on the machine could interact..."

If one has rogue processes doing bad things on your machine then it's game over already.

It's not clear to me how my suggestion makes this worse.

For servers listening on TCP port, even if only on localhost, this "rogue process" can be a webpage - see 1524 - project-zero - Project Zero - Monorail, for example (TL;DR: the specially crafted webpage was able to execute arbitrary code on system through server opened by uTorrent).

As you've ascertained by now, the answer is that there isn't yet anything production ready, but many in progress. Some of the most significant, in no particular order:

  • Relm uses GTK (limiting portability) and has lots of examples, but is mostly just a wrapper around GTK
  • Druid attempts to build portable UIs around standard system UI tools (e.g. standard text libraries) and its own event-handling model; it has e.g. rich-text and decent widget layout but support is less consistent across platforms; has an active community
  • Iced uses winit for windowing and wgpu or glow for rendering; it has an active community and many features, but still a long way to go (complex text, keyboard navigation, animations)
  • KAS (my own project); like Iced this uses winit and wgpu (currently not others like glow or CPU rendering or direct X11/win32/... bindings, though this would be possible), has better support for keyboard navigation/control and complex text layout than most of the above and significantly different event model, but behind in other areas (no image support, likely harder to learn)
  • OrbTk uses SDL and has pretty widgets but appears somewhat limited
  • fltk-rs (bindings to FLTK); has some quite capable examples, e.g. paint, gallery, tables, and a terminal. Another example of why it might be best not to use a Rust-native toolkit just yet?
  • Tauri allows use of HTML/JS/CSS front-ends on the desktop (see next post)

Something all of the above lack (if I'm not mistaken) is good support for complex data models. For example, the 7GUIs GUI benchmark has a CRUD test, including a dynamic view over data (required by the filter). Representing this type of data is not trivial. It does not necessarily require complex data management support within the GUI framework, e.g. Iced's "todos" example, but there are usually limitations (performance, complex data-handling implementations in the app itself).

4 Likes

:+1: That's a very helpful list, thank you. :slight_smile:


I'll add that I've had great success with Tauri on my company's Open Source Juju Lens application. I run the same app with limited features as a web interface, and then use Tauri to make less than 6MB installers for Windows, Mac, and Linux. The most annoying part was dealing with Windows builds, which ended up working on GitHub Actions, and making sure the web UI supported Windows Edge, which is used for the Windows build.

You avoid some of the pitfalls of using a web browser and a web server because the only way that you communicate from Rust to the webview is by eval-ing JavaScript directly through the webview, which mean's there's no HTTP. Technically an HTTP server ( in my app, Tauri has the option to disable it ) is still serving the static HTTP assets, but those are just the assets and it's not a security risk because you can't actually interface with the app through that. It's the same assets you'd get if you hit the website.

I embedded a custom websocket implementation powered by Tokio Tungstenite, and an SSH implementation that is used by calling APIs exposed by Rust from the web interface. It's really quite slick. I used Quasar for the UI design.

The result is an extremely professional, lightweight, and powerful desktop application combination. I wouldn't say it is suitable for every application, but it's definitely a compelling option.

https://github.com/zicklag/bin-dump/raw/master/juju-lens.mp4

( sorry the video performance is slow, I had to record over X forwarding, which unfortunately lowers the performance of the awesome animations )

BTW @tensor-programming and the rest of the Tauri devs, I love Tauri. :smiley: :tada:

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.