1. 新建目录 ui
2. go mod init ui
3. 新建 main.go
package main
import (
. "github.com/lxn/walk/declarative"
)
func main() {
mw := MainWindow{
Title: "测试窗口",
Size: Size{500, 500},
Layout: VBox{MarginsZero: true},
Children: []Widget{
TextLabel{
Text: "hello world",
},
},
}
mw.Run()
}
4. 新建 ui.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>
</assembly>
5. go get github.com/akavel/rsrc
6. rsrc -manifest ui.manifest -o ui.syso
7. go mod tidy
8. go mod vendor
9. go build -ldflags="-H windowsgui -w -s"
官方文档