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

 

 

[sourcecode language=”go” autolinks=”false” classname=”myclass” collapse=”false” firstline=”1″ gutter=”true” highlight=”1-3,6,9″ htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false” title=”Source Code main.go”] 
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()
}

[/sourcecode]

 

[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

 

 

Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: