Fyne GoLang GUI Course ICON – Tutorial 12
Here is the single line code to create a ICON widget.
// Creating Icon Widget IconX := widget.NewIcon(theme.CancelIcon())
Here is the 2nd step to show the content(ICON widget) on our screen(canvas)
// setup content w.SetContent(IconX)
package main
// importing Fyne
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
func main() {
// creating app
a := app.New()
// create window
w := a.NewWindow("Icon : tutorial")
//resizing windows
w.Resize(fyne.NewSize(400, 400))
// Creating Icon Widget
IconX := widget.NewIcon(theme.CancelIcon())
// setup content
w.SetContent(IconX)
// show windows
w.ShowAndRun()
}
[easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main12.go” text=”Download Code” color=”red_darker”]
Fyne GoLang GUI Course