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 🙂
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
}
Fyne GoLang GUI Course