建手机网站,阿里云怎么申请域名,做网站设计都做些什么,wordpress站群被谷歌k-1 字体支持
iced0.10.0 仅支持指定系统内置字体(iced默认字体中文会乱码) iced0.10.0 手动加载字体的功能已经砍了#xff0c;想手动加载就用0.9.0版本#xff0c;文档0.9.0版本 想显示中文则需要运行在一个自带字体的Windows系统上。而且这个字体最好不要钱。 (Windows闲着…-1 字体支持
iced0.10.0 仅支持指定系统内置字体(iced默认字体中文会乱码) iced0.10.0 手动加载字体的功能已经砍了想手动加载就用0.9.0版本文档0.9.0版本 想显示中文则需要运行在一个自带字体的Windows系统上。而且这个字体最好不要钱。 (Windows闲着没事不会给你放免费字体进去都是微软自己买的只能微软用)
如果选用的字体用户的电脑里恰好没有iced就直接乱码给你看。
0、准备
1、安装Visual Studio C Build tools
1、访问微软官网下载生成工具 2、勾选这个 3、对比勾选细节 4、点击安装 5、安装完成 6、关闭Visual Studio Installer 7、重启电脑
2、安装Rust
访问Rust官网下载 RUSTUP-INIT.EXE64位 在 PowerShell 中运行$ENV:RUSTUP_DIST_SERVERhttps://mirrors.ustc.edu.cn/rust-static;$ENV:RUSTUP_UPDATE_ROOThttps://mirrors.ustc.edu.cn/rust-static/rustup;.\rustup-init.exe输入1并回车
3、设置cargo镜像
运行powershell -command ii (where.exe cargo).substring(0,(where.exe cargo).Length-\bin\cargo.exe.Length) 在.cargo目录下新建文件名为config无后缀名保存为以下内容
[source.crates-io]
registry https://github.com/rust-lang/crates.io-index
replace-with ustc
[source.ustc]
registry git://mirrors.ustc.edu.cn/crates.io-index4、安装VSCode
访问这个链接如何下载安装VSCode 安装插件简体中文、rust-analyzer(中英双语版)
5、下载并安装字体文件
下载思源黑体下载链接 双击 SourceHanSansSC-Regular.otf 文件点击安装
0、编程
1、使用cargo创建项目
运行cargo new iced-progress_bar;cd iced-progress_bar
2、添加板条箱iced0.10.0
运行cargo add iced0.10.0
3、使用VSCode打开项目
运行code . 选中.\iced-progress_bar\src\main.rs激活插件等待插件加载完毕。
5、运行
运行cargo run等待编译完成正常输出Hello, world!
6、编辑.\iced-progress_bar\src\main.rs
6.1、use
编辑第一部分使用use关键字添加板条箱iced
// https://blog.csdn.net/qq_39124701/article/details/132662186
use iced::font::{Family, Weight};
use iced::widget::{button, column, progress_bar, slider, text};
use iced::{window, Element, Font, Sandbox, Settings};6.2、Progress
编辑第二部分添加一个结构体
#[derive(Default)]
struct Progress {value: f32,
}6.3、Message
编辑第二部分添加一个枚举
#[derive(Debug, Clone, Copy)]
enum Message {SliderChanged(f32),RunCommand,
}6.4、impl
6.4.1、编辑第三部分定义方法
impl Sandbox for Progress {}6.4.2、鼠标选中该行代码点击灯泡图标选择Implement missing members并保存 6.4.3、将会自动生成如下代码
impl Sandbox for Progress {type Message;fn new() - Self {todo!()}fn title(self) - String {todo!()}fn update(mut self, message: Self::Message) {todo!()}fn view(self) - Element_, Self::Message {todo!()}
}6.4.4、type Message 将type Message;改为type Message Message; 6.4.5、new() 将 fn new() - Self {todo!()}改为 fn new() - Self {Self::default()}6.4.6、title() 将 fn title(self) - String {todo!()}改为 fn title(self) - String {String::from(进度条 - Iced)}6.4.7、update() 将 fn update(mut self, message: Self::Message) {todo!()}改为 fn update(mut self, message: Message) {match message {Message::SliderChanged(x) self.value x,Message::RunCommand {std::process::Command::new(cmd).args([/C, start, , https://blog.csdn.net/qq_39124701/article/details/132662186]).spawn().expect(Failed to open URL);}}}6.4.8、view() 将 fn view(self) - Element_, Self::Message {todo!()}改为 fn view(self) - ElementMessage {// https://blog.csdn.net/qq_39124701/article/details/132662186column![text(self.value).size(50),progress_bar(0.0..100.0, self.value),slider(0.0..100.0, self.value, Message::SliderChanged).step(0.01),button(重置为零).on_press(Message::SliderChanged(0.0)),button(作者CSDN 三巧).on_press(Message::RunCommand),].padding(20).spacing(5).into()}6.5、main
将
fn main() {println!(Hello, world!);
}改为
pub fn main() - iced::Result {Progress::run(Settings {window: window::Settings {size: (500, 500),..Default::default()},default_font: Font {family: Family::Name(思源黑体),weight: Weight::Normal,..Default::default()},..Default::default()})
}7、运行
运行cargo run等待编译完成显示窗口 滑动滑块数字变化进度条变化 点击重置为零按钮数字归零进度条归零
8、构建
cargo build 生成位置.\iced-progress_bar\target\debug\iced-progress_bar.exe
9、exe运行有黑框
编辑.\iced-progress_bar\src\main.rs在第一行添加#![windows_subsystem windows]后重新构建即可
10、其他
iced官网 crates.io中的iced Github上的iced