forked from fyne-io/fyne
/
dialogs.go
48 lines (41 loc) · 1.03 KB
/
dialogs.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"errors"
"time"
"fyne.io/fyne"
"fyne.io/fyne/dialog"
"fyne.io/fyne/widget"
)
// Dialogs loads a window that lists the dialog windows that can be tested.
func Dialogs(app fyne.App) {
win := app.NewWindow("Dialogs")
win.SetContent(widget.NewVBox(
widget.NewButton("Info", func() {
dialog.ShowInformation("Information", "You should know this thing...", win)
}),
widget.NewButton("Error", func() {
err := errors.New("A dummy error message")
dialog.ShowError(err, win)
}),
widget.NewButton("Confirm", func() {
cnf := dialog.NewConfirm("Confirmation", "Are you enjoying this demo?", confirmCallback, win)
cnf.SetDismissText("Nah")
cnf.SetConfirmText("Oh Yes!")
cnf.Show()
}),
widget.NewButton("Progress", func() {
prog := dialog.NewProgress("MyProgress", "Nearly there...", win)
go func() {
num := 0.0
for num < 1.0 {
time.Sleep(50 * time.Millisecond)
prog.SetValue(num)
num += 0.01
}
prog.SetValue(1)
}()
prog.Show()
}),
))
win.Show()
}