diff --git a/golang_learn/data_func/go_to_walk/demo20/icon.ico b/golang_learn/data_func/go_to_walk/demo20/icon.ico new file mode 100644 index 0000000..c1e4b0e Binary files /dev/null and b/golang_learn/data_func/go_to_walk/demo20/icon.ico differ diff --git a/golang_learn/data_func/go_to_walk/demo20/main.go b/golang_learn/data_func/go_to_walk/demo20/main.go new file mode 100644 index 0000000..93a85a5 --- /dev/null +++ b/golang_learn/data_func/go_to_walk/demo20/main.go @@ -0,0 +1,61 @@ +package main + +import ( + "github.com/lxn/walk" + "log" +) + +// TODO 报错 +func main() { + GuiInit() +} + +func GuiInit() { + mw, err := walk.NewMainWindow() + if err != nil { + log.Fatal(err) + } + //托盘图标文件 + icon, err := walk.Resources.Icon("./icon.ico") + if err != nil { + log.Fatal(err) + } + ni, err := walk.NewNotifyIcon(mw) + if err != nil { + log.Fatal(err) + } + defer ni.Dispose() + if err := ni.SetIcon(icon); err != nil { + log.Fatal(err) + } + if err := ni.SetToolTip("鼠标在icon上悬浮的信息."); err != nil { + log.Fatal(err) + } + ni.MouseDown().Attach(func(x, y int, button walk.MouseButton) { + if button != walk.LeftButton { + return + } + if err := ni.ShowCustom( + "Walk 任务栏通知标题", + "walk 任务栏通知内容", + icon); err != nil { + log.Fatal(err) + } + }) + exitAction := walk.NewAction() + if err := exitAction.SetText("右键icon的菜单按钮"); err != nil { + log.Fatal(err) + } + //Exit 实现的功能 + exitAction.Triggered().Attach(func() { walk.App().Exit(0) }) + if err := ni.ContextMenu().Actions().Add(exitAction); err != nil { + log.Fatal(err) + } + if err := ni.SetVisible(true); err != nil { + log.Fatal(err) + } + if err := ni.ShowInfo("Walk NotifyIcon Example", "Click the icon to show again."); err != nil { + log.Fatal(err) + } + mw.Run() +} diff --git a/golang_learn/data_func/go_to_walk/demo21/main.go b/golang_learn/data_func/go_to_walk/demo21/main.go new file mode 100644 index 0000000..8ca6579 --- /dev/null +++ b/golang_learn/data_func/go_to_walk/demo21/main.go @@ -0,0 +1,79 @@ +// Copyright 2011 The Walk Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "github.com/lxn/walk" + "log" +) + +// TODO 报错 +func main() { + // We need either a walk.MainWindow or a walk.Dialog for their message loop. + // We will not make it visible in this example, though. + mw, err := walk.NewMainWindow() + if err != nil { + log.Fatal(err) + } + + // We load our icon from a file. + icon, err := walk.Resources.Icon("E://stop.ico") + if err != nil { + log.Fatal(err) + } + + // Create the notify icon and make sure we clean it up on exit. + ni, err := walk.NewNotifyIcon(mw) + if err != nil { + log.Fatal(err) + } + defer ni.Dispose() + + // Set the icon and a tool tip text. + if err := ni.SetIcon(icon); err != nil { + log.Fatal(err) + } + if err := ni.SetToolTip("Click for info or use the context menu to exit."); err != nil { + log.Fatal(err) + } + + // When the left mouse button is pressed, bring up our balloon. + ni.MouseDown().Attach(func(x, y int, button walk.MouseButton) { + if button != walk.LeftButton { + return + } + + if err := ni.ShowCustom( + "Walk NotifyIcon Example", + "There are multiple ShowX methods sporting different icons.", + icon); err != nil { + + log.Fatal(err) + } + }) + + // We put an exit action into the context menu. + exitAction := walk.NewAction() + if err := exitAction.SetText("E&xit"); err != nil { + log.Fatal(err) + } + exitAction.Triggered().Attach(func() { walk.App().Exit(0) }) + if err := ni.ContextMenu().Actions().Add(exitAction); err != nil { + log.Fatal(err) + } + + // The notify icon is hidden initially, so we have to make it visible. + if err := ni.SetVisible(true); err != nil { + log.Fatal(err) + } + + // Now that the icon is visible, we can bring up an info balloon. + if err := ni.ShowInfo("Walk NotifyIcon Example", "Click the icon to show again."); err != nil { + log.Fatal(err) + } + + // Run the message loop. + mw.Run() +} diff --git a/golang_learn/data_func/go_to_walk/demo21/stop.ico b/golang_learn/data_func/go_to_walk/demo21/stop.ico new file mode 100644 index 0000000..c1e4b0e Binary files /dev/null and b/golang_learn/data_func/go_to_walk/demo21/stop.ico differ diff --git a/golang_learn/data_func/go_to_windows/image/icon.ico b/golang_learn/data_func/go_to_windows/image/icon.ico new file mode 100644 index 0000000..c1e4b0e Binary files /dev/null and b/golang_learn/data_func/go_to_windows/image/icon.ico differ diff --git a/golang_learn/data_func/go_to_windows/main.go b/golang_learn/data_func/go_to_windows/main.go index e87df0c..d2a088a 100644 --- a/golang_learn/data_func/go_to_windows/main.go +++ b/golang_learn/data_func/go_to_windows/main.go @@ -863,3 +863,53 @@ func Contains(array []fs.FileInfo, val string) (index int) { func (mw *myApp) aboutactionTriggered() { walk.MsgBox(mw.mw, "功能说明", Info, walk.MsgBoxIconQuestion) } + +func GuiInit() { + mw, err := walk.NewMainWindow() + if err != nil { + log.Fatal(err) + } + //托盘图标文件 + icon, err := walk.Resources.Icon("./image/icon.ico") + if err != nil { + log.Fatal(err) + } + ni, err := walk.NewNotifyIcon(mw) + if err != nil { + log.Fatal(err) + } + defer ni.Dispose() + if err := ni.SetIcon(icon); err != nil { + log.Fatal(err) + } + if err := ni.SetToolTip("鼠标在icon上悬浮的信息."); err != nil { + log.Fatal(err) + } + ni.MouseDown().Attach(func(x, y int, button walk.MouseButton) { + if button != walk.LeftButton { + return + } + if err := ni.ShowCustom( + "Walk 任务栏通知标题", + "walk 任务栏通知内容", + icon); err != nil { + log.Fatal(err) + } + }) + exitAction := walk.NewAction() + if err := exitAction.SetText("右键icon的菜单按钮"); err != nil { + log.Fatal(err) + } + //Exit 实现的功能 + exitAction.Triggered().Attach(func() { walk.App().Exit(0) }) + if err := ni.ContextMenu().Actions().Add(exitAction); err != nil { + log.Fatal(err) + } + if err := ni.SetVisible(true); err != nil { + log.Fatal(err) + } + if err := ni.ShowInfo("Walk NotifyIcon Example", "Click the icon to show again."); err != nil { + log.Fatal(err) + } + mw.Run() +} diff --git a/golang_learn/data_func/go_to_windows/winView.go b/golang_learn/data_func/go_to_windows/winView.go index 03f176a..e47e8e7 100644 --- a/golang_learn/data_func/go_to_windows/winView.go +++ b/golang_learn/data_func/go_to_windows/winView.go @@ -21,36 +21,36 @@ func GetWindows() error { MenuItems: []MenuItem{ Menu{ Text: "&编辑", - // Image: "./image//media.png", + // Image: "./image/media.png", Items: []MenuItem{ Separator{}, Action{ - // Image: "./image//qinghuancun.png", + // Image: "./image/qinghuancun.png", Text: "清除缓存", OnTriggered: clearAll, }, Action{ - // Image: "./image//beifen.png", + // Image: "./image/beifen.png", Text: "重构索引", OnTriggered: reDbIndex, }, Action{ - // Image: "./image//beifen.png", + // Image: "./image/beifen.png", Text: "数据备份", OnTriggered: dbBak, }, //Action{ - // // Image: "./image//huanyuan.png", + // // Image: "./image/huanyuan.png", // Text: "数据还原", // OnTriggered: reDbBak, //}, Action{ - // Image: "./image//qinghuancun.png", + // Image: "./image/qinghuancun.png", Text: "数据清洗", OnTriggered: clearData, }, Action{ - // Image: "./image//tuichu.png", + // Image: "./image/tuichu.png", Text: "退出", OnTriggered: func() { walk.App().Exit(0) @@ -60,16 +60,16 @@ func GetWindows() error { }, Menu{ Text: "&设置", - // Image: "./image//shezhi.png", + // Image: "./image/shezhi.png", Items: []MenuItem{ Separator{}, Action{ - // Image: "./image//shujuku.png", + // Image: "./image/shujuku.png", Text: "设置数据库内存", OnTriggered: setDbSize, }, Action{ - // Image: "./image//yingyong.png", + // Image: "./image/yingyong.png", Text: "设置应用内存", OnTriggered: setServerSize, }, @@ -77,16 +77,16 @@ func GetWindows() error { }, Menu{ Text: "&表册", - // Image: "./image//shezhi.png", + // Image: "./image/shezhi.png", Items: []MenuItem{ Separator{}, Action{ - // Image: "./image//shujuku.png", + // Image: "./image/shujuku.png", Text: "按照职务输出生成(可能人员重复)", OnTriggered: getMcByA0281, }, Action{ - // Image: "./image//yingyong.png", + // Image: "./image/yingyong.png", Text: "按照主职务生成(可能人员丢失)", OnTriggered: getMcByA0279, }, @@ -94,15 +94,15 @@ func GetWindows() error { }, Menu{ Text: "&帮助", - // Image: "./image//bangzhu.png", + // Image: "./image/bangzhu.png", Items: []MenuItem{ Action{ - // Image: "./image//guanyu.png", + // Image: "./image/guanyu.png", Text: "关于", OnTriggered: app.aboutactionTriggered, }, /*Action{ - // Image: "./image//yaoqiu.png", + // Image: "./image/yaoqiu.png", Text: "要求", OnTriggered: app.aboutactionTriggered, },*/ diff --git a/golang_learn/go.sum b/golang_learn/go.sum index bb2db1a..380390d 100644 --- a/golang_learn/go.sum +++ b/golang_learn/go.sum @@ -37,6 +37,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +fyne.io/fyne v1.4.3 h1:356CnXCiYrrfaLGsB7qLK3c6ktzyh8WR05v/2RBu51I= +fyne.io/fyne v1.4.3/go.mod h1:8kiPBNSDmuplxs9WnKCkaWYqbcXFy0DeAzwa6PBO9Z8= fyne.io/fyne/v2 v2.1.4 h1:bt1+28++kAzRzPB0GM2EuSV4cnl8rXNX4cjfd8G06Rc= fyne.io/fyne/v2 v2.1.4/go.mod h1:p+E/Dh+wPW8JwR2DVcsZ9iXgR9ZKde80+Y+40Is54AQ= github.com/360EntSecGroup-Skylar/excelize v1.4.1 h1:l55mJb6rkkaUzOpSsgEeKYtS6/0gHwBYyfo5Jcjv/Ks= @@ -94,13 +96,17 @@ github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3 h1:FDqhDm7pcsLhhWl1QtD8 github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3/go.mod h1:CzM2G82Q9BDUvMTGHnXf/6OExw/Dz2ivDj48nVg7Lg8= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fyne-io/mobile v0.1.2 h1:0HaXDtOOwyOTn3Umi0uKVCOgJtfX73c6unC4U8i5VZU= +github.com/fyne-io/mobile v0.1.2/go.mod h1:/kOrWrZB6sasLbEy2JIvr4arEzQTXBTZGb3Y96yWbHY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk= github.com/go-gl/gl v0.0.0-20210813123233-e4099ee2221f h1:s0O46d8fPwk9kU4k1jj76wBquMVETx7uveQD9MCIQoU= github.com/go-gl/gl v0.0.0-20210813123233-e4099ee2221f/go.mod h1:wjpnOv6ONl2SuJSxqCPVaPZibGFdSci9HFocT9qtVYM= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200625191551-73d3c3675aa3/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211024062804-40e447a793be h1:Z28GdQBfKOL8tNHjvaDn3wHDO7AzTRkmAXvHvnopp98= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211024062804-40e447a793be/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-ini/ini v1.62.0 h1:7VJT/ZXjzqSrvtraFp4ONq80hTcRQth1c9ZnQ3uNQvU= @@ -109,6 +115,7 @@ github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -226,6 +233,7 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lucor/goinfo v0.0.0-20200401173949-526b5363a13a/go.mod h1:ORP3/rB5IsulLEBwQZCJyyV6niqmI7P4EWSmkug+1Ng= github.com/lucor/goinfo v0.0.0-20210802170112-c078a2b0f08b/go.mod h1:PRq09yoB+Q2OJReAmwzKivcYyremnibWGbK7WfftHzc= github.com/lxn/walk v0.0.0-20210112085537-c389da54e794 h1:NVRJ0Uy0SOFcXSKLsS65OmI1sgCCfiDUPj+cwnH7GZw= github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ= @@ -510,6 +518,7 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200720211630-cb9d2d5c5666/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -558,6 +567,7 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190808195139-e713427fea3f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -580,6 +590,7 @@ golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200328031815-3db5fc6bac03/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=