#对话框 #包装器 #Linux #zenity

zenity-dialog

为Linux的Zenity对话框渲染工具提供静态类型包装器

9个版本

使用旧的Rust 2015

0.3.6 2024年6月3日
0.3.5 2024年6月3日
0.3.3 2024年5月31日
0.2.2 2024年5月29日
0.1.1 2024年5月28日

#165 in 日期和时间

Download history 489/week @ 2024-05-25 431/week @ 2024-06-01 31/week @ 2024-06-08 2/week @ 2024-06-15 99/week @ 2024-07-27

每月99次下载

MIT/Apache

32KB
660

Zenity-Dialog

围绕Zenity(Linux中用于渲染对话框的工具)的薄包装器。此mvp版本仅支持有限的Zenity选项。

注意:此库假定Zenity已经安装,如果未找到,将抛出错误。您需要在应用程序中提供适当的文档,传达安装Zenity的需求。

何时使用此库?

想象你正在构建某种应用程序,该应用程序需要在某些情况下从用户那里获取一些输入,但由于某种原因,用户无法看到stdout。一个例子可能是用户启动的后台进程没有将stdout发送到终端;另一个例子可能是被桌面应用程序调用的CLI工具,可能是作为插件的一部分。此库允许你显示用户肯定能看到的并能做出响应的内容。

用法

let result = ZenityDialog::new(dialog::Error::default().with_text("An error happened!"))
    .with_icon(Icon::Error)
    .show()?;

    match result {
        ZenityOutput::Affirmed { .. } => {
            println!("The user clicked the affirmative response")
        }
        ZenityOutput::Rejected { .. } => println!("The user clicked the rejection response"),
        ZenityOutput::Unknown {
            exit_code,
            stdout,
            stderr,
        } => println!("Something weird happened. {exit_code} {stdout} {stderr}"),
    };

功能

Chrono

使用Chrono启用Calendar类型的自动日期解析。当此功能启用时,您无法将自定义日期格式传递给Zenity,因为这可能会干扰Chrono正确解析日期的能力。

依赖关系

~0.4–1.2MB
~24K SLoC