-
Notifications
You must be signed in to change notification settings - Fork 1
/
error.go
53 lines (46 loc) · 1.06 KB
/
error.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
package main
import (
"github.com/astaxie/beego/logs"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)
func boxAction(from walk.Form, title string, icon *walk.Icon, message string) {
var dlg *walk.Dialog
var cancelPB *walk.PushButton
_, err := Dialog{
AssignTo: &dlg,
Title: title,
Icon: icon,
MinSize: Size{210, 150},
Size: Size{210, 150},
MaxSize: Size{310, 210},
CancelButton: &cancelPB,
Layout: VBox{},
Children: []Widget{
TextLabel{
Text: message,
MinSize: Size{200, 150},
MaxSize: Size{300, 200},
},
PushButton{
AssignTo: &cancelPB,
Text: "OK",
OnClicked: func() {
dlg.Accept()
},
},
},
}.Run(from)
if err != nil {
logs.Error(err.Error())
}
}
func ErrorBoxAction(form walk.Form, message string) {
boxAction(form, "Error", walk.IconError(), message)
}
func InfoBoxAction(form walk.Form, message string) {
boxAction(form, "Info", walk.IconInformation(), message)
}
func ConfirmBoxAction(form walk.Form, message string) {
boxAction(form, "Warning", walk.IconWarning(), message)
}