Just so you know, I am fairly new to Rust. I’m using Pop OS Linux on the desktop where I do my work.
The project I am working on will need to do quite a lot of text editing. That means that whatever GUI crate I end up using will need to work well in that mode. It is likely that I will need to include a text editor as part of the end product. I didn’t see a text editor listed with the examples. Is Iced appropriate for that kind of programming or is it more focused on gaming and graphics? Just trying to get a feel for the crate and the type of coding it is focused on.
That looks good! Thanks! I see you use the async keyword. If I use this code at all I’ll have to bone up on how that is used.
My project very quickly got to the point that I needed to start bringing in a GUI interface and I originally settled on FLTK. It seems to work well, but, since I am still quite new to Rust, I need really good documentation. Maybe my gripe here is unfair, but it seems that since fltk.rs is basically a wrapper around a library written in C++ the documentation is really lacking. I haven’t been able to find a good Rust-based reference and, since I don’t program in C++, C++ based references are difficult for me to use. So, I spend all my time trying to find out how to use a particular function or trait and thus bog down in my efforts to make some progress on my project. So, I went looking, ran across lib.rs as an alternative to crates.io, and found Iced.rs. Am I right that Iced is entirely written in Rust, rather than wrapping around functions written in some other language? Anyway, I’m hoping that the documentation for Iced turns out to be well done. I’m going to spend some time experimenting with it anyway. :>)
Ok, so I’ve been trying to run some of the examples and keep getting unresolved import errors from the compiler. What all do I need in my cargo.toml file in order to use Iced? Apparently iced = "0.10" isn’t enough.
Okay. I’ll try that, but, and keep in mind that I’m still assessing Iced, how do I find out what needs to be put in the dependency section? I put iced = "0.10" in my cargo.toml, but is that the most recent/best version to use right now?
0.10 is the last released version but that doesn’t have the text editor feature @hecrj showed. If you want to use the unreleased feature he demoed you need to specify the git dependency with the snipped I shared instead of the crates.io dependency.
Well, I copied your snippet into my Cargo.toml and still get lots of errors. I want to take a look at that editor example, but, since it’s new, I may be jumping the gun. I’ll wait a bit and come back to it later. In the meantime, I’ll try out some of the other examples and dig into the documentation.
Well, apparently there is something I’m not understanding about how you are setting up dependencies in the cargo.toml file. I can’t seem to get any of the examples to run. I’ve tried multiple setups, but still no success. Best to give you an example. I’ll use the Checkbox example. Here’s what I did:
Copied the code for main() into my editor and saved it.
Copied the Cargo.toml file provided with the example and saved it.
In the terminal did cargo run.
The result was the following error message:
error: failed to parse manifest at `/home/camascounty/programming/rust/mine/my_gui/Cargo.toml`
error inheriting `iced` from workspace root manifest's `workspace.dependencies.iced`
failed to find a workspace root
My assumption is that the dependencies are saved in a folder you are calling workspace root. I have no way to access that.
TLDR: I’d recommend reading the Rust Book for learning some of the basics; Iced is fairly advanced and not the easiest to get into if you’re still learning Rust.
It looks like you’re attempting to copy the the checkbox package into a new project? In that case, the reason it’s failing is because the setup for the examples directory assumes you’ve pulled down the entire iced repository. In which case, you don’t have a workspace in your project, that’s something you’d set up manually. In your case though, it’s unnecessary.
Starting from an entirely blank project, to get iced into your project you just need a Cargo.toml that looks like this:
name = "test_iced"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
iced = "0.10.0"
Of course, the name and version should be whatever is proper for your project.
If you want the specific demo that hecrj showed as a screenshot, then you’d replace the iced line in the dependencies section of Cargo.toml with the line that avsaase shared above.