Does anyone have a working example (simpler the better) of a Rust program that uses GTK4 and draws graphical stuff, not just text? All I can find on the web either use GTK3 or are coded in C rather than rust. There is a nice tutorial at Building a Simple To-Do App - GUI development with Rust and GTK 4, but it uses only textual widgets.
You are asking about Cairo drawing? I ported my toy chess game to Rust recently, see GitHub - StefanSalewski/rust-chess: Port of salewski-chess from Nim to Rust. The GUI stuff is still ugly, sorry. But maybe it helps you to start with cairo. I can currently not remember other Rust cairo examples, but I would assume there is something in gtk4-rs/examples at master · gtk-rs/gtk4-rs · GitHub. Personally, I have some hope for Xilem and Vello for the end of this year.
[EDIT]
OK, I think I found the page with the Rust Cairo examples again:
And I think this file was my actual starting point for Cairo drawing on the GTK DrawingArea:
examples/src/bin/cairotest.rs at master · gtk-rs/examples · GitHub
or
rgtk/examples/src/cairotest.rs at master · jeremyletang/rgtk · GitHub
Many thanks for that, Stefan. I tried to build your chess project, but it needs GTK4 version 4.10 and my system has only 4.6.9. Fixed it by removing the 'features = ["v4_12"]' from Cargo.toml. I'm sure the source code will give me lots of good examples anyway.
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.