golang如何开发windows窗⼝界⾯
golang 如何开发windows窗⼝界⾯
调⽤包
go get github/lxn/walk
使⽤walk写⼀个简单的window应⽤程序
package main
import (
"log"
"strings"
"github/lxn/walk"
."github/lxn/walk/declarative"
)
func init(){
log.SetFlags(log.Ldate|log.Lshortfile)
}
func main(){
var inTE,outTE *walk.TextEdit
MainWindow{
Title: "test",
MinSize: Size{600,400},
Layout: VBox{},
Children: []Widget{
HSplitter{
Children:[]Widget{
TextEdit{AssignTo:&inTE,MaxLength:10},
TextEdit{AssignTo:&outTE,ReadOnly:true},
},
},
PushButton{
Text: "SCREAM",
OnClicked: func(){
outTE.SetText(strings.ToUpper(inTE.Text()))windows开发平台
},
},
},
}.Run()
}
在程序中嵌⼊⼆进制资源⼯具
go get github/akavel/rsrc
拉取下来之后,就会在GOPATH/src/bin中会发现有⼀个
在上⾯例⼦的同⽂件下,创建⼀个gui.mainifest的⽂件,并且在⾥⾯写⼊:
<?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>
然后运⾏
rsrc -manifest gui.manifest -o rsrc.syso
然后编译该⽂件
go build -ldflags="-H windowsgui"
点击运⾏即可
⽂件结构为
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论