e60a0b0427 | ||
---|---|---|
.. | ||
AUTHORS | ||
LICENSE | ||
README.mdown | ||
accessibility.go | ||
action.go | ||
actionlist.go | ||
application.go | ||
bitmap.go | ||
boxlayout.go | ||
brush.go | ||
button.go | ||
cancelevent.go | ||
canvas.go | ||
checkbox.go | ||
clipboard.go | ||
closeevent.go | ||
color.go | ||
combobox.go | ||
commondialogs.go | ||
composite.go | ||
condition.go | ||
container.go | ||
cursor.go | ||
customwidget.go | ||
databinding.go | ||
dateedit.go | ||
datelabel.go | ||
dialog.go | ||
dropfilesevent.go | ||
error.go | ||
errorevent.go | ||
event.go | ||
expression.go | ||
flowlayout.go | ||
font.go | ||
fontresource.go | ||
form.go | ||
gradientcomposite.go | ||
graphicseffects.go | ||
gridlayout.go | ||
groupbox.go | ||
icon.go | ||
iconcache.go | ||
image.go | ||
imagelist.go | ||
imageview.go | ||
inifilesettings.go | ||
intevent.go | ||
intrangeevent.go | ||
keyboard.go | ||
keyevent.go | ||
label.go | ||
layout.go | ||
lineedit.go | ||
linklabel.go | ||
listbox.go | ||
mainloop_cgo.go | ||
mainloop_default.go | ||
mainwindow.go | ||
maptablemodel.go | ||
menu.go | ||
messagebox.go | ||
metafile.go | ||
models.go | ||
mouseevent.go | ||
notifyicon.go | ||
numberedit.go | ||
numberlabel.go | ||
path.go | ||
pen.go | ||
point.go | ||
progressbar.go | ||
progressindicator.go | ||
property.go | ||
pushbutton.go | ||
radiobutton.go | ||
rectangle.go | ||
reflectmodels.go | ||
registry.go | ||
resourcemanager.go | ||
scrollview.go | ||
separator.go | ||
simpletypes.go | ||
size.go | ||
slider.go | ||
spacer.go | ||
splitbutton.go | ||
splitter.go | ||
splitterhandle.go | ||
splitterlayout.go | ||
static.go | ||
statusbar.go | ||
stopwatch.go | ||
stringevent.go | ||
tableview.go | ||
tableviewcolumn.go | ||
tableviewcolumnlist.go | ||
tabpage.go | ||
tabpagelist.go | ||
tabwidget.go | ||
textedit.go | ||
textlabel.go | ||
toolbar.go | ||
toolbutton.go | ||
tooltip.go | ||
tooltiperrorpresenter.go | ||
treeitemevent.go | ||
treeview.go | ||
util.go | ||
validators.go | ||
walk.go | ||
webview.go | ||
webview_dwebbrowserevents2.go | ||
webview_events.go | ||
webview_idochostuihandler.go | ||
webview_ioleclientsite.go | ||
webview_ioleinplaceframe.go | ||
webview_ioleinplacesite.go | ||
widget.go | ||
widgetlist.go | ||
window.go | ||
windowgroup.go |
README.mdown
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