go语言的一个gui 开源 项目 https://github.com/andlabs/ui
1 安装 mingw-w64 链接地址:
http://mingw-w64.sourceforge.net/download.php
2 liteide 配置:
# native compiler windows 386
GOROOT=c:\go
GOBIN=%GOROOT%\bin
GOARCH=386
GOOS=windows
CGO_ENABLED=1
PATH=C:\Program Files\mingw-w64\i686-4.9.2-win32-dwarf-rt_v3-rev1\mingw32\bin;%GOROOT%\bin;%PATH%
#GOPATH=c:\go
LITEIDE_GDB=gdb
LITEIDE_MAKE=make
LITEIDE_TERM=%COMSPEC%
LITEIDE_TERMARGS=
LITEIDE_EXEC=%COMSPEC%
LITEIDE_EXECOPT=/C
3 考入例子源码:
package main import ( "github.com/andlabs/ui" ) var window ui.Window func main() { go ui.Do(func() { name := ui.NewTextField() button := ui.NewButton("Greet") greeting := ui.NewLabel("") stack := ui.NewVerticalStack( ui.NewLabel("Enter your name:"), name, button, greeting) window = ui.NewWindow("Hello", 200, 100, stack) button.OnClicked(func() { greeting.SetText("Hello, " + name.Text() + "!") }) window.OnClosing(func() bool { ui.Stop() return true }) window.Show() }) err := ui.Go() if err != nil { panic(err) } }
4 效果截图:
有疑问加站长微信联系(非本文作者)