class 6 fyne GoLang GUI HYPERLINK
Have you ever link a webiste in your blogpost or MSOFFICE file or HTML page?
This is the same anchor we normally use to link to a site.
package main
// importing fyne
import (
"net/url"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget"
)
func main() {
// creating new app
a := app.New()
// creating new window
w := a.NewWindow("Here is Hyperlink widget")
w.Resize(fyne.NewSize(400, 400))
// creating url
url, _ := url.Parse("https://google.com")
// hyperLink Widget
// first value is label
// 2nd value is URL/ website address
hyperlink := widget.NewHyperlink("Visit me", url)
// setup content
w.SetContent(hyperlink)
w.ShowAndRun() // show and run
}
[easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main6.go” text=”Download Code” color=”red_darker”]
Fyne GoLang GUI Course