Layout NewVBox NewHBox – Fyne GUI Golang tutorial 15
If you want to use and display more than one widges in GUI App. You need to use layout.
Though we have tons of choices. But we are going to use to simple layout for horizontal and vertical.
For Horizontal layout we will use NewHBox layout. | ||
![]() | NewHBox , Horizontal Layout |
And for Vertical we are going to use NewVBox layout. | ||
![]() | NewVBox , Vertical Layout |
package main // importing fyne import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" ) func main() { // creating new app a := app.New() // creating new window and title w := a.NewWindow("Layout NewVBox and NewHbox") w.Resize(fyne.NewSize(400, 400)) // New button btn1 := widget.NewButton("click me", func() { }) label1 := widget.NewLabel("here is my text") // NewHBox box1 := container.NewHBox( // Horizontal btn1, label1, ) // NewVBox // box1 := container.NewVBox( // Vertical // btn1, // label1, // ) // setup content w.SetContent( box1, ) // show and run w.ShowAndRun() }
[easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main15.go” text=”Download Code” color=”red_darker”]
Fyne GoLang GUI Course