NewHSplit() Widget – Fyne GUI Golang tutorial 21
This tutorial is totally based on Fyne & Golang.
In this tutorial we are going to explain how to split your GUI window into two parts
A very basic and simple layout widget NewHSplit() is used.
What is NewHSplit()?
It will split your window into two horizontal parts
What is NewVSplit()?
It will split your window into two vertical parts
[sourcecode lang=”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
// import Fyne
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
func main() {
// New App
a := app.New()
// New Title And Window
w := a.NewWindow("NewHSplit Widget in Fyne")
//Resize
w.Resize(fyne.NewSize(400, 400))
// 1st widget
label1 := canvas.NewText("Text1", color.Black)
label2 := canvas.NewText("Text2", color.Black)
w1 := widget.NewIcon(theme.CancelIcon())
btn1 := widget.NewButton("Play ", func() {
})
// Setup Content
w.SetContent(
container.NewHSplit(
container.NewVBox(
label1,
w1,
),
// 2nd Section
container.NewVBox(
label2,
btn1,
),
),
)
w.ShowAndRun()
}
Fyne Golang GUI Course