Top Related Projects
Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly
Cross platform GUI toolkit in Go inspired by Material Design
Platform-native GUI library for Go.
Cross-platform Go/Golang GUI library.
Tiny cross-platform webview library for C/C++. Uses WebKit (GTK/Cocoa) and Edge WebView2 (Windows).
Quick Overview
lxn/walk is a Windows GUI toolkit for the Go programming language. It provides a native Windows look and feel for Go applications, allowing developers to create Windows desktop applications with a familiar interface using Go.
Pros
- Native Windows look and feel
- Comprehensive set of UI controls and widgets
- Good performance due to direct Windows API usage
- Active development and community support
Cons
- Limited to Windows platform only
- Steeper learning curve compared to cross-platform GUI libraries
- Documentation could be more extensive
- Some advanced UI features may require additional effort to implement
Code Examples
- Creating a simple window with a button:
package main
import (
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)
func main() {
_, err := MainWindow{
Title: "Hello Walk",
MinSize: Size{Width: 300, Height: 200},
Layout: VBox{},
Children: []Widget{
PushButton{
Text: "Click Me",
OnClicked: func() {
walk.MsgBox(nil, "Hello", "You clicked me!", walk.MsgBoxIconInformation)
},
},
},
}.Run()
if err != nil {
panic(err)
}
}
- Creating a simple data binding example:
package main
import (
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)
func main() {
var inTE, outTE *walk.TextEdit
MainWindow{
Title: "Data Binding Example",
MinSize: Size{Width: 300, Height: 200},
Layout: VBox{},
Children: []Widget{
TextEdit{AssignTo: &inTE},
TextEdit{AssignTo: &outTE, ReadOnly: true},
PushButton{
Text: "Copy",
OnClicked: func() {
outTE.SetText(inTE.Text())
},
},
},
}.Run()
}
- Creating a simple list view:
package main
import (
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)
func main() {
var lv *walk.ListView
MainWindow{
Title: "ListView Example",
MinSize: Size{Width: 300, Height: 200},
Layout: VBox{},
Children: []Widget{
ListView{
AssignTo: &lv,
Columns: []ListViewColumn{
{Title: "Name"},
{Title: "Value"},
},
},
},
}.Run()
items := [][]string{
{"Item 1", "Value 1"},
{"Item 2", "Value 2"},
{"Item 3", "Value 3"},
}
for _, item := range items {
lv.Items().Add(walk.ListViewItem{Text: item[0], Texts: item})
}
}
Getting Started
To get started with lxn/walk, follow these steps:
- Install Go on your Windows machine.
- Open a command prompt and run:
go get github.com/lxn/walk
- Create a new Go file (e.g.,
main.go
) and import the library:import ( "github.com/lxn/walk" . "github.com/lxn/walk/declarative" )
- Write your GUI code using the examples provided above as a starting point.
- Build and run your application:
go build ./your_app.exe
Competitor Comparisons
Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly
Pros of Qt
- Cross-platform support for multiple operating systems (Windows, macOS, Linux, Android, iOS)
- Rich set of UI components and widgets for creating complex interfaces
- Extensive documentation and large community support
Cons of Qt
- Larger binary size and resource footprint
- Steeper learning curve, especially for developers new to Qt framework
- Licensing considerations for commercial applications
Code Comparison
Walk example:
package main
import "github.com/lxn/walk"
func main() {
walk.MsgBox(nil, "Hello", "Hello, World!", walk.MsgBoxOK)
}
Qt example:
package main
import (
"os"
"github.com/therecipe/qt/widgets"
)
func main() {
app := widgets.NewQApplication(len(os.Args), os.Args)
window := widgets.NewQMainWindow(nil, 0)
window.SetWindowTitle("Hello")
window.Show()
app.Exec()
}
Both examples demonstrate creating a simple window or message box, but Qt requires more setup code for the application and main window. Walk provides a more straightforward approach for basic Windows GUI applications, while Qt offers more flexibility and cross-platform capabilities at the cost of increased complexity.
Cross platform GUI toolkit in Go inspired by Material Design
Pros of Fyne
- Cross-platform support (Windows, macOS, Linux, mobile)
- Modern, material design-inspired UI
- Active development and community support
Cons of Fyne
- Larger application size due to bundled dependencies
- Steeper learning curve for developers familiar with native GUI frameworks
Code Comparison
Walk example:
mw := new(MyMainWindow)
if _, err := MainWindow.Run(); err != nil {
fmt.Println(err)
}
Fyne example:
app := app.New()
w := app.NewWindow("Hello")
w.SetContent(widget.NewLabel("Hello Fyne!"))
w.ShowAndRun()
Key Differences
- Walk is Windows-specific, while Fyne is cross-platform
- Walk uses native Windows controls, Fyne uses custom rendering
- Fyne has a more modern API and design philosophy
- Walk may be more suitable for traditional Windows desktop applications
- Fyne is better suited for cross-platform and mobile development
Use Cases
Walk:
- Windows-only desktop applications
- Applications requiring native Windows look and feel
Fyne:
- Cross-platform desktop and mobile applications
- Modern, material design-inspired UIs
- Rapid prototyping and development of GUI applications
Platform-native GUI library for Go.
Pros of ui
- Cross-platform support (Windows, macOS, Linux)
- More modern and actively maintained
- Simpler API design for basic UI elements
Cons of ui
- Less comprehensive widget set compared to walk
- Fewer examples and documentation available
- Still in alpha stage, potential for breaking changes
Code Comparison
walk:
window := walk.NewMainWindow()
button, _ := walk.NewPushButton(window)
button.SetText("Click me")
button.Clicked().Attach(func() {
walk.MsgBox(window, "Hello", "You clicked the button!", walk.MsgBoxOK)
})
ui:
window := ui.NewWindow("Window Title", 200, 100, false)
button := ui.NewButton("Click me")
button.OnClicked(func(*ui.Button) {
ui.MsgBox(window, "Hello", "You clicked the button!")
})
window.SetChild(button)
Both libraries provide similar functionality for creating basic UI elements, but ui has a slightly more concise syntax. walk offers more detailed control over layouts and widgets, while ui aims for simplicity and cross-platform consistency. The choice between the two depends on specific project requirements, target platforms, and desired level of UI customization.
Cross-platform Go/Golang GUI library.
Pros of govcl
- Supports multiple platforms (Windows, Linux, macOS) using Lazarus LCL
- Provides a rich set of UI components and controls
- Offers both high-level and low-level APIs for flexibility
Cons of govcl
- Requires external dependencies (Lazarus LCL)
- May have a steeper learning curve due to its comprehensive feature set
- Less idiomatic Go code compared to walk
Code Comparison
walk example:
mw := new(MyMainWindow)
if _, err := walk.NewMainWindow(mw); err != nil {
log.Fatal(err)
}
mw.Run()
govcl example:
type TForm1 struct {
*vcl.TForm
}
var form1 *TForm1
func main() {
vcl.Application.Initialize()
vcl.Application.CreateForm(&form1)
vcl.Application.Run()
}
Summary
walk is a Windows-specific GUI toolkit with a more idiomatic Go approach, while govcl offers cross-platform support and a richer set of components at the cost of external dependencies and potentially more complex usage. The choice between them depends on the specific project requirements, target platforms, and developer preferences.
Tiny cross-platform webview library for C/C++. Uses WebKit (GTK/Cocoa) and Edge WebView2 (Windows).
Pros of webview
- Cross-platform support (Windows, macOS, Linux)
- Lightweight and easy to integrate
- Uses native web engines for rendering
Cons of webview
- Limited native UI controls
- Requires web technologies knowledge
- May have performance overhead for complex UIs
Code comparison
webview:
package main
import "github.com/webview/webview"
func main() {
w := webview.New(true)
defer w.Destroy()
w.SetTitle("Webview Example")
w.SetSize(800, 600, webview.HintNone)
w.Navigate("https://example.com")
w.Run()
}
walk:
package main
import (
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)
func main() {
MainWindow{
Title: "Walk Example",
MinSize: Size{Width: 600, Height: 400},
Layout: VBox{},
Children: []Widget{
PushButton{Text: "Click Me"},
},
}.Run()
}
The webview example demonstrates creating a simple web-based window, while the walk example shows creating a native Windows GUI with a button. webview offers a more straightforward approach for web-based interfaces, while walk provides more control over native Windows UI elements.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
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
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
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 version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="SomeFunkyNameHere" type="win32"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True</dpiAware>
</windowsSettings>
</application>
</assembly>
Then either compile the manifest using the rsrc tool, 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 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.
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
Top Related Projects
Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly
Cross platform GUI toolkit in Go inspired by Material Design
Platform-native GUI library for Go.
Cross-platform Go/Golang GUI library.
Tiny cross-platform webview library for C/C++. Uses WebKit (GTK/Cocoa) and Edge WebView2 (Windows).
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot