赞
踩
iced是rust语言开发的一个跨平台GUI库(Windows、macOS、Linux、Web),介绍请参见:https://docs.rs/iced/0.3.0/iced/index.html
在Ubuntu下使用的话,需要先安装freetype库:
sudo apt install libfreetype-dev
本文通过代码实验,了解窗口参数(iced::window::Settings)的意义。
Cargo.toml:
[package]
name = "Hello_iced"
version = "0.1.0"
authors = ["wuu19 <wuu19@163.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
iced = {version = "0.3.0"}
font-kit = {version = "0.10.0", optional = true}
main.rs:
use iced::{executor, Application, Clipboard, Command, Element, Settings, Text}; pub fn main() -> iced::Result { Hello::run(Settings{ // 设置窗口属性 window:iced::window::Settings{ size: (1600, 900), resizable: false, decorations: true, transparent: false, always_on_top: false, ..iced::window::Settings::default() }, // 指定字体文件位置 default_font: Some(include_bytes!("/home/user/work/rust/font/DroidSansFallback.ttf")), ..Settings::default() }) } struct Hello; impl Application for Hello { type Executor = executor::Default; type Message = (); type Flags = (); fn new(_flags: ()) -> (Hello, Command<Self::Message>) { (Hello, Command::none()) } fn title(&self) -> String { String::from("A cool application") } fn update(&mut self, _message: Self::Message, _clipboard: &mut Clipboard) -> Command<Self::Message> { Command::none() } fn view(&mut self) -> Element<Self::Message> { Text::new("Hello, world!").into() } }
iced::window::Settings,属性说明如下:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。