Label

Widgets are the main components of a Fyne application GUI, they can be used in an place that a basic fyne.CanvasObject can. They manage user interactions but also will always match the current theme.

The Label widget is the simplest of them - it presents text to the user. Unlike canvas.Text it can handle some simple formatting (such as \n). You can create a label by calling widget.NewLabel("some text"), the result can be assigned to a variable or passed directly into a container.

Example Code

            
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package main

import (
	"fyne.io/fyne/app"
	"fyne.io/fyne/widget"
)

func main() {
	myApp := app.New()
	myWindow := myApp.NewWindow("Label Widget")

	content := widget.NewLabel("text")

	myWindow.SetContent(content)
	myWindow.ShowAndRun()
}