Fyne GoLang GUI Course ICON – Tutorial 12
Here is the single line code to create a ICON widget.
[sourcecode lang=”go”]
// Creating Icon Widget
IconX := widget.NewIcon(theme.CancelIcon())
[/sourcecode]
Here is the 2nd step to show the content(ICON widget) on our screen(canvas)
[sourcecode lang=”go”]
// setup content
w.SetContent(IconX)
[/sourcecode]
[sourcecode lang=”go” autolinks=”false” classname=”myclass” collapse=”false” firstline=”1″ gutter=”true” highlight=”1-3,6,9″ htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false” title=”Source Code main.go”]
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()
}
Fyne GoLang GUI Course