An idiomatic GUI library inspired by Elm and based on gtk4-rs. Relm4 is a new version of relm that's built from scratch and is compatible with GTK4 and libadwaita.
We believe that GUI development should be easy, productive and delightful.
The gtk4-rs crate already provides everything you need to write modern, beautiful and cross-platform applications.
Built on top of this foundation, Relm4 makes developing more idiomatic, simpler and faster and enables you to become productive in just a few hours.
Relm4 depends on GTK4: How to install GTK4.
Relm4 has two crates that extend the core functionality:
widget
macro that simplifies UI creationAdd this to your Cargo.toml
:
toml
gtk = { version = "0.3", package = "gtk4" }
relm4 = "0.2"
relm4-macros = "0.2"
relm4-components = "0.2"
The relm4 crate has two feature flags:
AsyncWorker
type that uses an async update functionSeveral example applications are available at relm4-examples/.
```rust use gtk::prelude::{BoxExt, ButtonExt, GtkWindowExt, OrientableExt}; use relm4::{send, AppUpdate, Model, RelmApp, Sender, WidgetPlus, Widgets};
struct AppModel { counter: u8, }
enum AppMsg { Increment, Decrement, }
impl Model for AppModel { type Msg = AppMsg; type Widgets = AppWidgets; type Components = (); }
impl AppUpdate for AppModel {
fn update(&mut self, msg: AppMsg, components: &(), _sender: Sender
impl Widgets
append = >k::Button {
set_label: "Increment",
connect_clicked(sender) => move |_| {
send!(sender, AppMsg::Increment);
},
},
append = >k::Button {
set_label: "Decrement",
connect_clicked(sender) => move |_| {
send!(sender, AppMsg::Decrement);
},
},
append = >k::Label {
set_margin_all: 5,
set_label: watch! { &format!("Counter: {}", model.counter) },
}
},
}
}
}
fn main() { let model = AppModel::default(); let app = RelmApp::new(model); app.run(); }
```
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Feedback and contributions are highly appreciated!