Class 3 fyne GoLang GUI TEXT Label
How to create your first Text Label in Fyne GUI?
It is very easy to create a Label
widget.NewLabel(“Here is my Lable”)
Now you can change it to any value.
But it should be string.
If you want to use any other data type you need to convert to string.
Which is again very easy.
Convert integer to String
fmt.Sprintf(“%d”, myInt)
Example
widget.NewLabel(fmt.Sprintf(“%d”, myInt))
Convert bool to String
fmt.Sprintf(“%t”, mybool)
Example
widget.NewLabel(fmt.Sprintf(“%t”, mybool))
package main import ( // importing fyne "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/widget" ) func main() { // New app a := app.New() //New Window w := a.NewWindow("Here is my title for 3 tutorial") // Resize Windows w.Resize(fyne.NewSize(300, 300)) // Our First widget labelX := widget.NewLabel("I can write anything") w.SetContent(labelX) w.ShowAndRun() // Running app }[easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main3.go” text=”Download Code” color=”red_darker”]
Fyne GoLang GUI Course