-
Notifications
You must be signed in to change notification settings - Fork 0
/
window.go
84 lines (73 loc) · 2.2 KB
/
window.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package main
import (
"errors"
"fmt"
"time"
"fyne.io/fyne"
"fyne.io/fyne/dialog"
"fyne.io/fyne/layout"
"fyne.io/fyne/widget"
)
func confirmCallback(response bool) {
fmt.Println("Responded with", response)
}
// DialogScreen loads a panel that lists the dialog windows that can be tested.
func DialogScreen(win fyne.Window) fyne.CanvasObject {
dialogs := widget.NewGroup("Dialogs",
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.Hide()
}()
prog.Show()
}),
widget.NewButton("Custom", func() {
content := widget.NewEntry()
content.SetPlaceHolder("Type something here")
content.OnChanged = func(text string) {
fmt.Println("Entered", text)
}
dialog.ShowCustom("Custom dialog", "Done", content, win)
}),
)
windows := widget.NewVBox(dialogs, widget.NewGroup("Windows",
widget.NewButton("New window", func() {
w := fyne.CurrentApp().NewWindow("Hello")
w.SetContent(widget.NewLabel("Hello World!"))
w.Show()
}),
widget.NewButton("Fixed size window", func() {
w := fyne.CurrentApp().NewWindow("Fixed")
w.SetContent(fyne.NewContainerWithLayout(layout.NewCenterLayout(), widget.NewLabel("Hello World!")))
w.Resize(fyne.NewSize(240, 180))
w.SetFixedSize(true)
w.Show()
}),
widget.NewButton("Centered window", func() {
w := fyne.CurrentApp().NewWindow("Central")
w.SetContent(fyne.NewContainerWithLayout(layout.NewCenterLayout(), widget.NewLabel("Hello World!")))
w.CenterOnScreen()
w.Show()
})))
return fyne.NewContainerWithLayout(layout.NewGridLayout(2), windows, LayoutPanel())
}