其实主要我是要花一个折线图,但是使用Fyne貌似画不出来,使用plot也没法动态生成,听说Gio可以,那就先介绍一下什么是Gio把。
GIO(gioui.org)是一个用于Go语言的跨平台GUI库,旨在为开发人员提供构建现代图形用户界面的工具。以下是关于GIO的一些关键点:
go get
来安装GIO库。 bash
复制
go get -u gioui.org/io@latest
package main import ( "fmt" "image/color" "log" "os" "gioui.org/app" "gioui.org/op" "gioui.org/text" "gioui.org/widget/material" ) func main() { go func() { window := new(app.Window) err := run(window) if err != nil { log.Fatal(err) } os.Exit(0) }() app.Main() } func run(window *app.Window) error { theme := material.NewTheme() theme.Bg = color.NRGBA{R: 0, G: 0, B: 0, A: 255} var ops op.Ops for { switch e := window.Event().(type) { case app.DestroyEvent: fmt.Println("destroy") return e.Err case app.FrameEvent: // This graphics context is used for managing the rendering state. gtx := app.NewContext(&ops, e) title := material.H1(theme, "Hello, Gio") // Change the color of the label. maroon := color.NRGBA{R: 127, G: 0, B: 0, A: 255} title.Color = maroon // Change the position of the label. title.Alignment = text.Middle // Draw the label to the graphics context. title.Layout(gtx) // Pass the drawing operations to the GPU. e.Frame(gtx.Ops) } } }