NewHSplit() Widget – Fyne GUI Golang tutorial 21

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

 

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

Download Code

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: