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:

STEP:1 Define the main package
package main
STEP:2 Import all the packages
import("fmt")
STEP:3 import fyne
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(){
}
STEP:5 Create a new app
a := app.New()
STEP:6 Create a new window with title
w := a.NewWindow("Fyne Button Widget TUT")
STEP:7 Set the app Window Size
w.Resize(fyne.NewSize(400,400))
STEP:8 Set content on screen
w.SetContent(
widget.NewButton("Fyne Button",func(){
    fmt.Println("Hello Fyne.")
}))
STEP:9 Show and Run
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

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.