-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (42 loc) · 948 Bytes
/
main.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
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/widget"
"github.com/leancodebox/fyneMiniProgram/resource"
"github.com/leancodebox/fyneMiniProgram/tm"
"os"
)
func main() {
a := app.New()
w := a.NewWindow("fyneMiniProgram")
a.SetIcon(resource.GetLogo())
a.Settings().SetTheme(&tm.MyTheme{})
hello := widget.NewLabel("欢迎使用fyneMiniProgram!")
w.SetContent(container.NewVBox(
hello,
widget.NewButton("你好", func() {
hello.SetText("Welcome :)")
}),
))
w.SetCloseIntercept(func() {
w.Hide()
})
// 桌面系统设置托盘
if desk, ok := a.(desktop.App); ok {
m := fyne.NewMenu("bigBrother",
fyne.NewMenuItem("关于", func() {
w.Show()
}),
fyne.NewMenuItem("退出", func() {
os.Exit(0)
}),
)
desk.SetSystemTrayMenu(m)
}
w.Resize(fyne.NewSize(300, 80))
w.SetFixedSize(true)
w.ShowAndRun()
}