fyne-widgets/examples/vumeter/main.go

30 lines
757 B
Go
Raw Normal View History

2021-12-10 20:09:01 +00:00
package main
import (
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
2021-12-11 00:13:18 +00:00
"git.martyn.berlin/martyn/fyne-widgets/pkg/vumeter"
2021-12-10 20:09:01 +00:00
)
func main() {
a := app.New()
2021-12-11 00:13:18 +00:00
w := a.NewWindow("VUMeter")
2021-12-10 20:09:01 +00:00
level := binding.NewFloat()
2021-12-11 00:13:18 +00:00
levelPB := vumeter.NewVUMeterWithData(level)
level.Set(0.95)
2021-12-10 20:09:01 +00:00
levelPB.TextFormatter = func() string { return " " }
2021-12-11 00:13:18 +00:00
progress := widget.NewProgressBarWithData(level)
setLevel := binding.NewFloat()
setLevel.Set(75.0)
slider := widget.NewSliderWithData(0.0, 100.0, setLevel)
slider.OnChanged = func(data float64) {
level.Set(data / 100)
}
2021-12-10 20:09:01 +00:00
2021-12-11 00:13:18 +00:00
w.SetContent(container.New(layout.NewVBoxLayout(), levelPB, progress, slider))
2021-12-10 20:09:01 +00:00
w.ShowAndRun()
}