环境搭建
golang环境
go get github.com/mattn/go-gtk/gtk
gtk依赖库
sudo apt-get install libgtk2.0-dev libglib2.0-dev libgtksourceview2.0-dev
开启CGO_ENABLED编译环境
go env -w CGO_ENABLED=1
go-gtk示例
package main
import (
"fmt"
"os"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(&os.Args)
win := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
win.SetTitle("go gtk")
win.SetSizeRequest(480, 320)
win.Show()
gtk.Main()
}
启动程序 go run main.go