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
| package main
import (
"github.com/tailscale/walk"
. "github.com/tailscale/walk/declarative"
"log"
)
type MyMainWindow struct {
*walk.MainWindow
}
func main() {
app, err := walk.InitApp()
if err != nil {
log.Fatal(err)
}
mw := new(MyMainWindow)
MainWindow{
AssignTo: &mw.MainWindow,
Title: "Hi walk", // 窗口标题
MinSize: Size{Width: 400, Height: 500}, // 最小尺寸
Size: Size{Width: 400, Height: 500}, // 尺寸
Layout: VBox{}, // 窗口布局
Children: []Widget{
Label{
Text: "请选择模式",
Alignment: AlignHCenterVCenter,
},
PushButton{
Text: "短时间高频休息",
OnClicked: mw.shortLayout,
},
PushButton{
Text: "长时间低频休息",
},
},
}.Create()
app.Run()
}
func (mw *MyMainWindow) shortLayout() {
shortMainWindow := new(MyMainWindow)
MainWindow{
AssignTo: &shortMainWindow.MainWindow,
Title: "短时间高频休息",
MinSize: Size{Width: 400, Height: 500}, // 最小尺寸
Size: Size{Width: 400, Height: 500}, // 尺寸
Layout: VBox{},
Children: []Widget{
Label{Text: "Hello"},
},
}.Create()
shortMainWindow.Running()
}
|