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))
[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 (
// 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
}

[/sourcecode] [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

 

Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: