Class 4: Fyne GoLang GUI – Using Buttons
Welcome back to our Fyne and GoLang GUI course! ???? In this fourth class, we’ll dive into how to use buttons in Fyne. This tutorial will guide you through writing a simple program to create a window and add button functionality. We’ll cover the following steps:
package main
import("fmt")
import("fyne.io/fyne/v2/app") import("fyne.io/fyne/v2") import("fyne.io/fyne/v2/widget")
STEP:4 Define the main function
func main(){ }
a := app.New()
w := a.NewWindow("Fyne Button Widget TUT")
w.Resize(fyne.NewSize(400,400))
w.SetContent( widget.NewButton("Fyne Button",func(){ fmt.Println("Hello Fyne.") }))
w.ShowAndRun()
By the end of this video, you’ll know how to effectively use buttons 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 all the packages import("fmt") //import fyne import("fyne.io/fyne/v2/app") import("fyne.io/fyne/v2") import("fyne.io/fyne/v2/widget") func main(){ //Create a new app a := app.New() //Create a new window with title w := a.NewWindow("Fyne Button Widget TUT") //Set the app Window Size w.Resize(fyne.NewSize(400,400)) //Set content on screen w.SetContent( widget.NewButton("Fyne Button",func(){ fmt.Println("Hello Fyne.") })) //Show and Run w.ShowAndRun() }
#Fyne #GoLang #GUI #Programming #Tutorial #Coding #SoftwareDevelopment #AppDevelopment #LearnToCode #ButtonWidget #FyneTutorial #GolangGUI #TechEducation #BeginnerProgramming #OpenSource