/walk

A Windows GUI toolkit for the Go Programming Language

Primary LanguageGoOtherNOASSERTION

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

Go 1.0.x doesn't work with walk anymore, Make sure you use Go 1.1.x or later.

To Install

Now run go get github.com/kumakichi/walk

Using Walk

The preferred way to create GUIs with Walk is to use its declarative sub package, as illustrated in this small example:

main.go
package main

import (
    "github.com/kumakichi/walk"
    . "github.com/kumakichi/walk/declarative"
    "strings"
)

func main() {
    var inTE, outTE *walk.TextEdit
    var mw *walk.MainWindow

    if err := (MainWindow{
        AssignTo: &mw,
        Title:   "SCREAMO",
        MinSize: Size{300, 200},
        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()))
                },
            },
        },
    }.Create()); err != nil {
        // do some work
    }

	mainIcon, err := walk.NewIconFromResource("101")
	if err != nil {
        // do some work
	}
	mw.SetIcon(mainIcon)
    mw.Run()
}
Create Resource file version.rc
#include "winver.h"
#define RT_MANIFEST  24
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
//#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID 2
//#define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID 3
#define IDI_ICON_S 101
#define IMG_SET 102

IDI_ICON_S       ICON      "a.ico"
IMG_SET        BITMAP        "Settings.bmp"

CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST MOVEABLE PURE
{
 "<?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""/>"
     "<description>Your application description here.</description>"
         "<dependency>"
             "<dependentAssembly>"
                 "<assemblyIdentity type=""win32"" name=""Microsoft.Windows.Common-Controls"" version=""6.0.0.0"" processorArchitecture=""*"" publicKeyToken=""6595b64144ccf1df"" language=""*""/>"
             "</dependentAssembly>"
         "</dependency>"
 "</assembly>"
}

Then compile the resource file using the windres tool, like this:

windres -o version.syso version.rc
Build app

In the directory containing main.go run

go build

To get rid of the cmd window, instead run

go build -ldflags="-H windowsgui"
Run app
demo.exe
Sample Output (Windows XP)

alt tag

More Examples

There are some examples that should get you started.