Giter Club home page Giter Club logo

walk's Introduction

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.

walk's People

Watchers

 avatar  avatar  avatar

Forkers

skarm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.