https://github.com/lxn/walk
A Windows GUI toolkit for the Go Programming Language
https://github.com/lxn/walk
declarative declarative-ui go gui gui-toolkit win32 windows windows-desktop
Last synced: 7 months ago
JSON representation
A Windows GUI toolkit for the Go Programming Language
- Host: GitHub
- URL: https://github.com/lxn/walk
- Owner: lxn
- License: other
- Created: 2010-09-16T08:11:49.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2024-01-21T11:56:29.000Z (almost 2 years ago)
- Last Synced: 2025-04-25T17:54:54.448Z (7 months ago)
- Topics: declarative, declarative-ui, go, gui, gui-toolkit, win32, windows, windows-desktop
- Language: Go
- Homepage:
- Size: 5.2 MB
- Stars: 6,969
- Watchers: 256
- Forks: 901
- Open Issues: 346
-
Metadata Files:
- Readme: README.mdown
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
- go-awesome - walk - Windows GUI toolkit (开源类库 / 桌面开发)
- go-awesome - walk - Windows GUI toolkit (Open source library / Desktop Development)
- awesome-go - walk - A Windows GUI toolkit for the Go Programming Language - ★ 2987 (GUI)
- awesome-go-plus - walk - Windows application library kit for Go.  (GUI / Search and Analytic Databases)
- awesome-go - walk - Windows application library kit for Go. (GUI / Search and Analytic Databases)
- fucking-awesome-go - :octocat: walk - Windows application library kit for Go. :star: 1319 :fork_and_knife: 258 (GUI / Advanced Console UIs)
- awesome-go-cn - walk
- fucking-awesome-go - walk - Windows application library kit for Go. (GUI / Search and Analytic Databases)
- awesome-go - walk - | - | - | (GUI / Advanced Console UIs)
- awesome-go-cn - walk
- awesome-go - walk - Windows application library kit for Go. (GUI / Search and Analytic Databases)
- awesome-go - walk - Windows application library kit for Go. Stars:`7.0K`. (GUI / Search and Analytic Databases)
- awesome-golang-repositories - walk
- awesome-go - walk - Windows application library kit for Go. (GUI / Search and Analytic Databases)
- awesome-go - walk - Windows的应用程序库工具包。 (<span id="gui">GUI</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go - walk - Windows application library kit for Go. - :arrow_down:457 - :star:3116 (GUI / Advanced Console UIs)
- awesome-go - walk - Windows application library kit for Go. (GUI / Search and Analytic Databases)
- awesome-go-with-stars - walk - Windows application library kit for Go. (GUI / Search and Analytic Databases)
- awesome-go - lxn/walk
- awesome-go - walk - Windows application library kit for Go. (GUI / Search and Analytic Databases)
- awesome-Char - walk - Windows application library kit for Go. (GUI / Advanced Console UIs)
- awesome-go-cn - walk
- awesome-go - walk - Windows application library kit for Go. (GUI / Advanced Console UIs)
- awesome-go-cn - walk
- awesome-go - walk - Windows application library kit for Go. (GUI / Advanced Console UIs)
README
About Walk
==========
Walk is a "Windows Application Library Kit" for the Go Programming Language.
Its primarily useful for Desktop GUI development, but there is some more stuff.
Setup
=====
Make sure you have a working Go installation.
See [Getting Started](http://golang.org/doc/install.html)
##### Note
Walk currently requires Go 1.11.x or later.
##### To Install
Now run `go get github.com/lxn/walk`
Using Walk
==========
The preferred way to create GUIs with Walk is to use its declarative sub package,
as illustrated in this small example:
##### `test.go`
```go
package main
import (
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
"strings"
)
func main() {
var inTE, outTE *walk.TextEdit
MainWindow{
Title: "SCREAMO",
MinSize: Size{600, 400},
Layout: VBox{},
Children: []Widget{
HSplitter{
Children: []Widget{
TextEdit{AssignTo: &inTE},
TextEdit{AssignTo: &outTE, ReadOnly: true},
},
},
PushButton{
Text: "SCREAM",
OnClicked: func() {
outTE.SetText(strings.ToUpper(inTE.Text()))
},
},
},
}.Run()
}
```
##### Create Manifest `test.manifest`
```xml
PerMonitorV2, PerMonitor
True
```
Then either compile the manifest using the [rsrc tool](https://github.com/akavel/rsrc), like this:
go get github.com/akavel/rsrc
rsrc -manifest test.manifest -o rsrc.syso
or rename the `test.manifest` file to `test.exe.manifest` and distribute it with the application instead.
##### Build app
In the directory containing `test.go` run
go build
To get rid of the cmd window, instead run
go build -ldflags="-H windowsgui"
##### Run app
test.exe
##### Sample Output (Windows 7)

##### More Examples
There are some [examples](examples) that should get you started.
Application Manifest Files
==========================
Walk requires Common Controls 6. This means that you must put an appropriate
application manifest file either next to your executable or embedded as a
resource.
You can copy one of the application manifest files that come with the examples.
To embed a manifest file as a resource, you can use the [rsrc tool](https://github.com/akavel/rsrc).
IMPORTANT: If you don't embed a manifest as a resource, then you should not launch
your executable before the manifest file is in place.
If you do anyway, the program will not run properly. And worse, Windows will not
recognize a manifest file, you later drop next to the executable. To fix this,
rebuild your executable and only launch it with a manifest file in place.
CGo Optimizations
=================
The usual default message loop includes calls to win32 API functions, which incurs a decent amount
of runtime overhead coming from Go. As an alternative to this, you may compile Walk using an
optional C implementation of the main message loop, by passing the `walk_use_cgo` build tag:
go build -tags walk_use_cgo