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()
}

[/sourcecode] [easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main21.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: