Class 8 fyne GoLang GUI IMAGE
Images are very important part of any GUI design.
Fyne has a great support for images.
[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
// import fyne
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
)
func main() {
// New app
a := app.New()
// New Window and Title
w := a.NewWindow("Image in Fyne")
// resize window
w.Resize(fyne.NewSize(400, 400))
// Now Image widget
img := canvas.NewImageFromFile("c:/cartoon/health.jpg")
// setup content to show
w.SetContent(img)
// show and run
w.ShowAndRun()
}
Fyne GoLang GUI Course