Class 7 fyne GoLang GUI Text and Change Color


This is one of the most basic widget in every GUI programs.
You want to write simple text and want to give it some color. Hope so not red color 🙂

[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 (
"image/color"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
)

func main() {
// Create new app
a := app.New()

// Create New Window and Title
w := a.NewWindow("My Canvas Text Tutorial")
// Resize window
w.Resize(fyne.NewSize(400, 400))
// Our Text widget in Canvas
//first value for label/cation
// 2nd for color value
// Now creating Color
colorx := color.NRGBA{R: 0, G: 0, B: 255, A: 255}
// R is Red and Range is zero to 255
// B is blue and G is Green
// A is for alpha for opacity
textX := canvas.NewText("Here is my blue text", colorx)

// Setup widget.
w.SetContent(textX)
w.ShowAndRun() // Show and run App
}

[/sourcecode] [easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main7.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: