Featured image of post Uos环境下go-Gtk图形界面开发

Uos环境下go-Gtk图形界面开发

环境搭建

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

参考资料:

github/go-gtk
Go语言图形界面开发:Go版GTK
bbtool

Licensed under CC BY-NC-SA 4.0
最后更新于 2024-05-02 03:45 -0400