File.glade with Rust

I have now a rust Project in my Ubuntu - Works
I have made a GTK GUI with Glade and saved it to xyz.glade
i have GTK v3_22 in the dependencies in the Rust project - works i can display a window

now how can i display the GUI from Glade with my Rust program
and how can i give my nodes in the GUI event handler like in Java
node.addActionEvent(blabla)
llike how can i address the nodes in the GUI from my rust project

Have you seen the gtk-rs glade tutorial?

https://gtk-rs.org/docs-src/tutorial/glade

However, Glade is not recommend for GTK any more:

https://blogs.gnome.org/christopherdavis/2020/11/19/glade-not-recommended/

1 Like

i have couple of knowledge about programming languages and so on algorithm blabla...back end stuff...and rust seems for me like a logical language thats why i wanted to learn it by myself the issue was that rust has no GUI librarys like javafx yet so what do you recommend as a GUI tool that works with rust? im not like hardly focused on GTK i just want to make a GUI in addition to my program

If you are willing to check out other GUI libraries, I happen to have come across this article recently, it compares the most popular crates pretty well: A Survey of Rust GUI Libraries | boringcactus

I must admit I also find GTK to be a good default choice on Unix-like platforms because of its familiar API. I haven't extensively tried many other Rust-specific libraries, though.

Another good resource to check out from time to time is Are We GUI Yet?.

2 Likes

FLTK, mentioned in that article, also has an interface designer that is not deprecated:

https://www.fltk.org/doc-1.4/fluid.html

1 Like

ive read now about the both gtk articles and i understand the poins,
for my use glade supports enough the GUI for me atleast for now.
Where do i have to put my glade file?
i have my toml files and my src folder with main.rs adn where should i put the xml file then ?

Well, that's a blog post from a developer that is neither a Gtk developer neither a GNOME one and reflects his own experience, not those projects policies.

IMHO, Glade is still a great option to develop Gtk apps and developing them using Rust is, in fact, quite pleasant.

where do i have to put the glade file taht its readable in my project like where do i have to put it

If you read the tutorial that @kornel linked, the .glade file gets pulled in via include_str. So you can put the file anywhere you want, as long as you pass an appropriate path to include_str.

the path was the problem not the include :smiley:
normally for example a java program doesnt find any paths that are outside of the current path except you really try hard

From the include_str documentation:

The file is located relative to the current file (similarly to how modules are found).

So a possible layout would be

project/
|- Cargo.toml
|- interface.glade
|- src/
   |- whatever.rs

and then use include_str!("../interface.glade") in whatever.rs.

thanks i get it so its similiar to java that the current path is the root point

1 Like