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()}