Load Image from Internet – Fyne GUI Golang tutorial 28
Want to load images from internet and local storage. It is very easy in fyne Golang GUI.
fyne display image from internet
[/sourcecode]
[/sourcecode]
fyne display image from your computuer
Want to load images from computer and local storage. It is very simple. use Image widget.
[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”]img := canvas.NewImageFromFile("c:/assets/health.jpg")
[/sourcecode]In this example we are loading image from assets director/folder in C drive.
[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 title and window
w := a.NewWindow("Loading images from internet")
// resize
w.Resize(fyne.NewSize(400, 400))
// loading image form url
r, _ := fyne.LoadResourceFromURLString("https://picsum.photos/200")
img := canvas.NewImageFromResource(r)
w.SetContent(img)
//
w.ShowAndRun()
}
Fyne Golang GUI Course
fyne golang example to load images from internet, local storage computer. Golang fyne tutorial for beginners looking for source code with example.