Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

native-windows-gui

> 编程语言
Open source

A light windows GUI toolkit for rust

2.1K stars0 likes2 views
WebsiteGitHub

About

A light windows GUI toolkit for rust

Native Windows GUI

Welcome to Native Windows GUI (aka NWG). A rust library to develop native GUI applications on the desktop for Microsoft Windows.

NWG is a very light wrapper over WINAPI. It allows you, the developer, to handle the quirks and rough edges of the API by providing a simple, safe and rust-like interface.

Native Windows GUI keeps things simple. This means small compile times, minimal resource usage, less time searching the documentation and more time for you to develop your application.

Of course, you don't have to take my word for it, check out the showcase and the examples.

This is the 3rd and final version of NWG. It is considered "mature" or, as I would say "the backlog is empty, and it will most likely stay that way". This version implements pretty much everything required to develop applications on Windows. Don't bother using the older versions as they have "irreconcilable design decisions" and cannot support some key features. Future development will be done in other libraries.

If you've managed to read through this introduction, you should know that my twitter handle is #gdube_dev and you can support this project with GitHub Sponsors.

Any support is greatly appreciated.

Installation

To use NWG in your project add it to cargo.toml:

toml
[dependencies]
native-windows-gui = "1.0.12"
native-windows-derive = "1.0.3" # Optional. Only if the derive macro is used.

And then, in main.rs or lib.rs :

rust
extern crate native_windows_gui as nwg;
extern crate native_windows_derive as nwd;  // Optional. Only if the derive macro is used.

Rust 2018 aliasing

You can skip the extern crate define in your source code by adding the following code in Cargo.toml Note that procedural macros still require an extern crate definition, so this wont work with native-windows-derive

toml
[dependencies]
nwg = {version = "^1.0.12", package = "native-windows-gui"}

Trying it out

See it for yourself. NWG has plenty of examples and a fully interactive test suite. The only thing you need to do is:

…

Cross-compiling from Ubuntu

Requirement: MinGW compiler

bash
sudo apt install gcc-mingw-w64-x86-64

Requirement: Rust support

rustup target add x86_64-pc-windows-gnu

Compiling and running basic example:

cargo build --release --target=x86_64-pc-windows-gnu
cargo build --release --target=x86_64-pc-windows-gnu --example basic
wine target/x86_64-pc-windows-gnu/release/examples/basic.exe

Project structure

This is the main project git. It is separated in multiple sections

  • native-windows-gui
    • The base library. Includes an interactive test suite and plenty of examples
  • native-windows-derive
    • A procedural macro that generates the GUI application from rust structure (pretty cool stuff IMO)
  • docs/native-windows-docs read it online
    • Hefty documentation that goes over everything you need to know about NWG
  • showcase
    • Images of the examples. If you've made an NWG application and want to share it here, send me a message or open a PR. It's free real estate.

Supported features

  • The WHOLE winapi control library (reference)
    • Some very niche controls are not supported: flat scroll bar, ip control, rebar, and pager.
  • Menus and menu bar
  • Image and font resource
    • BMP
    • ICO
    • CUR
    • PNG*
    • GIF*
    • JPG*
    • TIFF*
    • DDS*
    • *: Extended image formats with the Windows Imaging Component (WIC).
  • Localization support
    • Uses Windows National Language Support internally (reference)
  • Tooltip
  • System tray notification
  • Cursor handling
  • A full clipboard wrapper
  • Partial templates support
    • Split large application into chunks
  • Dynamic controls support
    • Add/Remove controls at runtime
    • Bind or unbind new events at runtime
  • Multithreaded application support
    • Communicate to the GUI thread from another thread
    • Run multiple windows on different threads
  • Simple layout configurations
    • FlexboxLayout
    • GridLayout
  • Drag and drop
    • Drop files from the desktop to a window
  • The most common dialog boxes
    • File dialog (save, open, open folder)
    • Font dialog
    • Color dialog
  • A canvas that can be used by external rendering APIs
  • High-DPI aware
  • Support for accessibility functions
    • Tab navigation
  • Support for low level system message capture (HWND, MSG, WPARAM, LPARAM)
  • Cross compiling and testing from Linux to Windows with Wine and mingw.
    • Not all features are supported (but the majority are, thanks WINE!)
    • See https://zork.net/~st/jottings/rust-windows-and-debian.html for the steps to follow

Performance

This was measured on a Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz, 3401 Mhz, 4 Core(s), 8 Logical Processor(s)

In release mode, the basic example weighs 163kb on disk and takes 900kb in memory. Launch time is instantaneous.

The interactive test suite (with every feature and 100s of tests) weighs 931 kb on disk and takes 8MB in memory. Launch time is still instantaneous.

Initial build time takes around 22 seconds for a basic application. This is mainly due to winapi-rs initial compile time. Subsequent compile time takes around 0.7 seconds.

Development

The development of this library is considered "done". By that, I mean that there won't be any change to the API. Issues can be raised if a bug is found or if some area in the documentation is unclear. If I overlooked a very important feature, it will most likely be added.

License

NWG uses the MIT license

Code example

With native windows derive

…

Barebone example. Suitable if you only need a simple static UI

…

With the NativeUi boilerplate

…

Attributions

For the icons used in the test suite (and only there):

  • love.ico is made by Smashicons from www.flaticon.com
  • popcorn.bmp is made by Freepik from www.flaticon.com
  • ball.bmp is made by Freepik from www.flaticon.com
  • cat.jpg is made by Freepik from www.flaticon.com
  • weird_cat.png is made by Freepik from www.flaticon.com
  • list_0.png, list_1.png, list_2.png, list_3.png are made by Smashicons from www.flaticon.com
  • ice.cur is made by nrox653 from rw-designer

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustguinativenative-windows-guirust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言