Change & Customize app icons – Fyne GUI Golang tutorial 27

Change & Customize app icons – Fyne GUI Golang tutorial 27

It is very important to have a custom app icon and other graphics.

Fortunately it is very easy in Fyne GUI to use your own custom assets in your GUI APP.

How to use a default Fyne logo?

You can with “SetIcon” function. Example is given below

w.SetIcon(theme.fyneLogo())

How to use Custom Logo in Fyne App?

You have to load assets/ resource first from compute or internet. Like give below

 r, _ := fyne.LoadResourceFromPath("c:/assets/tree.jpg")
Now you can use this asset in the SetIcon function.
 a.SetIcon(r)
where ‘r’ is the variable of the resource.
package main

// import fyne
import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
)

func main() {
	// New app
	a := app.New()
	r, _ := fyne.LoadResourceFromPath("c:/assets/tree.jpg")
	// change icon
	a.SetIcon(r)
	// New window/ title
	w := a.NewWindow("change app icon")
	//resize
	w.Resize(fyne.NewSize(400, 400))
	w.ShowAndRun()
}

[easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main27.go” text=”Download Code” color=”red_darker”]

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: