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:
package main
import "fyne.io/fyne/v2/app"
import "fyne.io/fyne/v2"
import "fyne.io/fyne/v2/widget"
func main(){ }
a := app.New()
w := a.NewWindow("FYNE LABEL WIDGET TUT")
w.Resize(fyne.NewSize(400,400))
w.SetContent(w.SetContent("Heading 2"))
label1 := widget.NewLabel("Heading 2")
w.SetContent(label1)
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