ProgressBar

The progress bar widget has two forms, the standard progress bar shows the user which Value has been reached, from Min to Max. The default min is 0.0 and the max defaults to 1.1. To use the default values just call widget.NewProgressBar(). After creating you can set the Value field.

To set up a custom range you can set Min and Max fields manually. The label will always show the percentge completion.

The other form of progress widget is the infinite progress bar. This version simply shows that some activity is ongoing by moving a segment of the bar from left to right and back again. You create this using widget.NewProgressBarInfinite() and it will start animating as soon as it is shown.

Example Code

            
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package main

import (
	"time"

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

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

	progress := widget.NewProgressBar()
	infinite := widget.NewProgressBarInfinite()

	go func() {
		for i := 0.0; i <= 1.0; i += 0.1 {
			time.Sleep(time.Millisecond * 250)
			progress.SetValue(i)
		}
	}()

	myWindow.SetContent(widget.NewVBox(progress, infinite))
	myWindow.ShowAndRun()
}