Class 3: Fyne GoLang GUI – Using Label Widgets

 

Welcome back to our Fyne and GoLang GUI course! ???? In this third class, we’ll explore how to set content and use label widgets in Fyne. This tutorial will guide you through writing a simple program to create and resize a window, and set a label widget within the window. We’ll cover the following steps:

SETP: 1 Define the main package
package main
SETP: 2import the Fyne app package
import "fyne.io/fyne/v2/app"
SETP: 3 import the Fyne core package
import "fyne.io/fyne/v2"
SETP: 4 import the Fyne Widget Package
import "fyne.io/fyne/v2/widget"
SETP:  5 Define the main function
func main(){
}
SETP: 6 Create a new app instance
a := app.New()
SETP: 7 create a new window with a title
w := a.NewWindow("FYNE LABEL WIDGET TUT")
SETP: 8 Resize The Window(width:400, height:400)
w.Resize(fyne.NewSize(400,400))
SETP: 9 Set the of the Window With a label Widget
w.SetContent(w.SetContent("Heading 2"))
SETP:10  Optional
label1 := widget.NewLabel("Heading 2")
w.SetContent(label1)
SETP:11  Show the window and run the app
w.ShowAndRun()

By the end of this video, you’ll know how to use label widgets effectively in your Fyne applications. Don’t forget to like, comment, and subscribe for more coding tutorials! ????

SOURCE CODE


// Define the main package
package main
// import the Fyne app package
import "fyne.io/fyne/v2/app"
// import the Fyne core package
import "fyne.io/fyne/v2"
// import the Fyne Widget Package
import "fyne.io/fyne/v2/widget"
//Define the main function
func main(){
// Create a new app instance
a := app.New()
// create a new window with a title
w := a.NewWindow("FYNE LABEL WIDGET TUT")
// Resize The Window(width:400, height:400)
w.Resize(fyne.NewSize(400,400))
// Set the of the Window
//With a label Widget
// Optional
label1 := widget.NewLabel("Heading 2")
w.SetContent(label1)
// Show the window and run the app
w.ShowAndRun()
}

#Fyne #GoLang #GUI #Programming #Tutorial #Coding #SoftwareDevelopment #AppDevelopment #LearnToCode #LabelWidget #FyneTutorial #GolangGUI #TechEducation #BeginnerProgramming #OpenSource

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.