Widgets

A fyne.Widget is a special type of container that has additional logic associated with it. In widgets the logic is separate from the way that it looks (also called the WidgetRenderer).

Widgets are also types of CanvasObject and so we can set the content of our window to a single widget. See how we create a new widget.Entry and set it as the content of the window in this example.

As we saw in the previous example you can also add multiple objects to a canvas using a Container and the same can be done with sets of widgets to start building up graphical application interface.

Example Code

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

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

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

	myWindow.SetContent(widget.NewEntry())
	myWindow.ShowAndRun()
}