diff --git a/golang_learn/data_func/go_to_fyne/demo/main.go b/golang_learn/data_func/go_to_fyne/demo/main.go new file mode 100644 index 0000000..c39711b --- /dev/null +++ b/golang_learn/data_func/go_to_fyne/demo/main.go @@ -0,0 +1,95 @@ +package main + +import ( + "fyne.io/fyne" + "fyne.io/fyne/container" + "time" + + "fyne.io/fyne/app" + "fyne.io/fyne/widget" +) + +func main() { + // demo01() + // demo02() + // demo03() + demo04() +} + +// demo04 单元测试 +func demo04() { + a := app.New() + w := a.NewWindow("Hello Person") + + w.SetContent(container.NewVBox(makeUI())) + w.ShowAndRun() +} +func makeUI() (*widget.Label, *widget.Entry) { + out := widget.NewLabel("Hello world!") + in := widget.NewEntry() + + in.OnChanged = func(content string) { + out.SetText("Hello " + content + "!") + } + return out, in +} + +// demo03 设置窗口大小 - 控制主窗口 +func demo03() { + a := app.New() + w := a.NewWindow("Hello World") + + w.SetContent(widget.NewLabel("Hello World!")) + w.Show() + + w2 := a.NewWindow("Larger") + // 区别位置 + // w2.SetContent(widget.NewLabel("More content")) + w2.SetContent(widget.NewButton("Open new", func() { + w3 := a.NewWindow("Third") + w3.SetContent(widget.NewLabel("Third")) + w3.Show() + })) + w2.Resize(fyne.NewSize(100, 100)) + w2.Show() + + a.Run() +} + +// demo02 设置窗口大小 +func demo02() { + a := app.New() + w := a.NewWindow("Hello World") + + w.SetContent(widget.NewLabel("Hello World!")) + w.Show() + + w2 := a.NewWindow("Larger") + w2.SetContent(widget.NewLabel("More content")) + w2.Resize(fyne.NewSize(100, 100)) + w2.Show() + + a.Run() +} + +// demo01 更新界面的内容 +func demo01() { + a := app.New() + w := a.NewWindow("Clock") + + clock := widget.NewLabel("") + updateTime(clock) + + w.SetContent(clock) + go func() { + for range time.Tick(time.Second) { + updateTime(clock) + } + }() + w.ShowAndRun() +} + +func updateTime(clock *widget.Label) { + formatted := time.Now().Format("Time: 03:04:05") + clock.SetText(formatted) +} diff --git a/golang_learn/data_func/go_to_linux/demo02/main.go b/golang_learn/data_func/go_to_linux/demo02/main.go index 62e155c..fb66375 100644 --- a/golang_learn/data_func/go_to_linux/demo02/main.go +++ b/golang_learn/data_func/go_to_linux/demo02/main.go @@ -45,7 +45,8 @@ func main() { } defer session.Close() //执行远程命令 - combo, err := session.CombinedOutput("whoami; cd /opt/cn.com.epsoft.qggwy/qggwy/mysql/bin; ./mysql -uroot -padmin") + // combo, err := session.CombinedOutput("whoami; cd /opt/cn.com.epsoft.qggwy/qggwy/mysql/bin; ./mysql -uroot -padmin") + combo, err := session.CombinedOutput("whoami; cd /opt/apps/cn.com.epsoft.qggwy/files/qggwy/kingbase/bin; ./ksql -h127.0.0.1 -p35017 -Uhy_qggwy -dTEST; hy_qggwy") if err != nil { log.Fatal("远程执行cmd 失败", err) }