package main
import("log""fyne.io/fyne/v2/app""fyne.io/fyne/v2/widget")funcmain(){
myApp := app.New()
myWindow := myApp.NewWindow("Form Widget")
entry := widget.NewEntry()
textArea := widget.NewMultiLineEntry()
form :=&widget.Form{
Items:[]*widget.FormItem{// we can specify items in the constructor{Text:"Entry", Widget: entry}},
OnSubmit:func(){// optional, handle form submission
log.Println("Form submitted:", entry.Text)
log.Println("multiline:", textArea.Text)
myWindow.Close()},}// we can also append items
form.Append("Text", textArea)
myWindow.SetContent(form)
myWindow.ShowAndRun()}
progressbar进度条
package main
import("time""fyne.io/fyne/v2/app""fyne.io/fyne/v2/container""fyne.io/fyne/v2/widget")funcmain(){
myApp := app.New()
myWindow := myApp.NewWindow("ProgressBar Widget")
progress := widget.NewProgressBar()
infinite := widget.NewProgressBarInfinite()gofunc(){for i :=0.0; i <=1.0; i +=0.1{
time.Sleep(time.Millisecond *250)
progress.SetValue(i)}}()
myWindow.SetContent(container.NewVBox(progress, infinite))
myWindow.ShowAndRun()}
1.配置CGO_ENABLED为1
go env -w CGO_ENABLED1
2.安装gcc环境,否则出现cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%错误
安装包:链接:https://pan.baidu.com/s/1sgF9lijqGeP…