I want to use icons for my buttons to be more legible. Before iced 0.10.0 I did that via an additional Font::External, but unfortunately Font::External isn’t available anymore and I didn’t find any substitute or alternative.
As far as I know Button’s take iced::Element’s. If you want an icon on the left side, you can use a row. If you want it on the right side, row![text("bla bla bla").width(Length::Shrink), Space::new(Length::Fill, Length::Shrink), image(icon_handle).width(Length::Shrink or Length::Fixed(...)]
If you don’t want the image to be shrinked you can use Responsive in iced::lazy.
Thanks for the advice. I didn’t know I could insert widgets into Buttons! Great!
Sadly either svg nor png image is loaded or shown in the button.
But the button resizes to the give size, so an Image-object is created. Have you any advice for that?
This is an environment variable assignment, on Linux, MacOS or using WSL you can just add WGPU_BACKEND=VULKAN before your command just such as WGPU_BACKEND=VULKAN cargo run. Otherwise if you are on Windows you might find what you wnat in this document.
iced_aw::graphics::icons with icon_to_char → only displays a rectangle
including an image → it is not shown, neither png nor svg (png is in the example of iced!)
using a custom font: that worked until iced 0.9.0, where iced lost the ability to include an external font. At least I Font::External isn’t working anymore and the documentation of 0.10.0 has nothing similar to this that I found.
So I’m stuck with text buttons with clutter my UI. I have to find another way to do that or I learned Rust+Iced for nothing and go back to C++/Qt
Some ideas?
For your information: I’m using Debian 12 with Cinnamon and installed a newer version of Rust in my home directory (otherwise iced will not compile).
Thanks for the advice. Still only showing a empty rectangle.
Probably the error is in the Text widget? I had do embed the Icon as String::from(…), but this uses the default font, I guess?
But otherwise I get errors…
to load icons you must set the font for the Text to be that of the Icon you are using. Otherwise it will not find the icons and could output actual Text from another font instead. This means you need to have multiple Text’s one’s for Icons and Ones for Regular Text. As iced doesn’t allow from my understanding Setting separate parts of a string to different Fonts.
I have to admit: I think I’m too inexperienced with programming to deal with Rust and Iced, at least in the current state. I’m not a trained programmer, just doing things for my own sake and learning only with myself. It kinda worked with v0.9.0, but even there was e.g. no way to add a button with a String from a list (after all I didn’t find a way to do it) and more. ATM I will abandon Iced and write my whole application new with C++/Qt.
Problably I can come back at a later time.
Thanks for your help and patience! I appreciate that much.
Also part of learning is being able to figure out Errors and bugs. this is a crucial part actually as this better prepares you for other issues later on. So generally giving up tends to be a bad choice as if everything just works you are not really learning anything.
No, I did not, because the documentation doesn’t say anything about it and I’m to dumb, lazy and/or inexperienced to go through all the code available anywhere.
Also part of learning is being able to figure out Errors and bugs. this is a crucial part actually as this better prepares you for other issues later on. So generally giving up tends to be a bad choice as if everything just works you are not really learning anything.
I know that for sure. I’m a teacher But I don’t have the time all day to face all those problems, read code (I in total don’t understand) and see over missing documentation. Sorry
As you could guess, I’m just very frustrated at the moment with Rust and Iced. And frustration is no good point to go on. At least for now.