fyne-gui-demo3水平布局
示例图如下:
package main
import (
"fmt"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
// Layout 界面ui设计
func Layout() fyne.CanvasObject {
// 水平布局
return container.NewHBox(
widget.NewButton("button1", func() {
fmt.Println("button1 is clicked")
}),
widget.NewButton("button2", func() {
fmt.Println("button2 is clicked")
}),
)
}
func main() {
// 创建程序
thisApp := app.New()
// 创建窗口对象、传入窗口名
w := thisApp.NewWindow("Title")
// 设置窗口内容
w.SetContent(Layout())
// 窗口的显示和运行
w.ShowAndRun()
}