build_rust_nwg_gui

Generates Windows desktop GUI applications in Rust using native-windows-gui derive macros.

Updated Mar 15, 2026
One-click install
npx skills add https://github.com/mohankumargupta/skills --skill build-rust-nwg-gui-mohankumargupta
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: build_rust_nwg_gui
Source: https://github.com/mohankumargupta/skills/tree/main/guis/native-windows-gui
Command: npx skills add https://github.com/mohankumargupta/skills --skill build-rust-nwg-gui-mohankumargupta

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires native-windows-gui, native-windows-derive, embed-manifest, and includes references (resource) components.

What problem does it solve? Writing native Windows GUIs in Rust with the native-windows-gui (NWG) crate involves non-obvious pitfalls: Win32 controls that reject text colors, event handlers that cannot mutate state directly, and infinite event loops when syncing controls. This Skill encodes the correct patterns, workarounds, and a complete reference example so generated NWG applications compile and behave correctly on the first attempt. ## Core Features & Use Cases - Derive-Macro Architecture Guidance: Enforces the #[derive(NwgUi)] pattern with correct struct ordering (window, resources, layouts, controls, RefCell state) and proper Cargo.toml feature flags. - Pitfall Workarounds: Provides concrete fixes for colored text via RichLabel, background colors on Labels, password masking toggles, and recursion guards for syncing ListBoxes. - API Reference & Working Example: Ships a full widget/event reference and a complete MQTT Keyboard application demonstrating GridLayout, menus, fonts, and event handlers. - Use Case: Given a UI mockup description, generate a compilable Rust NWG application with grid layout, styled controls, and working event handlers including proper shutdown via nwg::stop_thread_dispatch(). ## Quick Start Ask the AI to build a Windows desktop GUI in Rust using native-windows-gui based on your layout description or mockup.

Frequently Asked Questions about build_rust_nwg_gui

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a Windows GUI in Rust with native-windows-gui?▼

Use the native-windows-derive crate with #[derive(Default, NwgUi)] on a struct. Define the Window first, then resources like fonts, then a GridLayout, then controls with #[nwg_control] and #[nwg_layout_item] attributes, and call nwg::dispatch_thread_events() in main.

How do I change text color on a native-windows-gui Label?▼

Standard nwg::Label cannot change text color via macros. Use nwg::RichLabel instead and call set_char_format in the OnInit handler with a CharFormat containing text_color as an RGB array.

Why does native-windows-gui state mutation fail in event handlers?▼

NWG event handlers take &self, so &mut self mutation is impossible. Wrap all mutable application state in std::cell::RefCell and use borrow_mut() inside handlers to update values safely.

How do I stop infinite event loops when syncing two ListBoxes?▼

Programmatically updating one ListBox fires its OnListBoxSelect event, causing recursion. Add an is_syncing RefCell<bool> flag, check it at handler entry, set it true before updating the other list, and reset it after.

How do I hide the console window in a Rust Windows GUI app?▼

Add #![windows_subsystem = "windows"] at the top of main.rs. This prevents the terminal window from appearing when the GUI application launches.

How do I mask and unmask a password field in native-windows-gui?▼

Use nwg::TextInput with password: Some('•') in the control macro. At runtime, call set_password_char(None) to reveal the text or set_password_char(Some('•')) to mask it again, typically from a CheckBox handler.