1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| package main import ( "fmt" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" ) func main() {
os.Setenv("FYNE_FONT", "font.otf")
myApp := app.New() myWindow := myApp.NewWindow("窗口名称")
myWindow.Resize(fyne.NewSize(400, 500)) myWindow.SetFixedSize(true)
myWindow.SetContent(widget.NewLabel("这是一行乱码"))
myWindow.SetContent(widget.NewCheck("选项1", func(b bool) { fmt.Println(b) })) url, _ := url.Parse("https://www.baidu.com") myWindow.SetContent(widget.NewHyperlink("百度", url)) textX := canvas.NewText("这是后面的文字", color.NRGBA{R: 0, G: 255, B: 255, A: 255}) myWindow.SetContent(textX) image := canvas.NewImageFromFile("1.png") myWindow.SetContent(image) circle := canvas.NewCircle(color.NRGBA{R: 0, G: 255, B: 255, A: 255}) circle.StrokeColor = color.NRGBA{R: 0, G: 0, B: 0, A: 255} circle.StrokeWidth = 10 myWindow.SetContent(circle) line := canvas.NewLine(color.Black) line.StrokeWidth = 3 line.StrokeColor = color.Black myWindow.SetContent(line) rect := canvas.NewRectangle(color.Black) rect.FillColor = color.RGBA{255, 255, 0, 100} rect.StrokeWidth = 2 rect.StrokeColor = color.RGBA{255, 0, 0, 255} myWindow.SetContent(rect)
myWindow.ShowAndRun() fmt.Println("exit...") }
|