From 3539402c3718dd542b6bf2ff29c348bb260475ae Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 29 Feb 2024 03:06:17 -0600 Subject: [PATCH] opens multiple windows in demo mode Signed-off-by: Jeff Carr --- Makefile | 4 ++++ fynetest.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ main.go | 21 +-------------------- stdin.go | 3 ++- 4 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 fynetest.go diff --git a/Makefile b/Makefile index 44da83c..3ecdb10 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,10 @@ all: plugin plugin: go build -v -x -buildmode=plugin -o ../fyne.so +non-plugin: + go build -v -x + ./fyne + check-git-clean: @git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1) diff --git a/fynetest.go b/fynetest.go new file mode 100644 index 0000000..8948948 --- /dev/null +++ b/fynetest.go @@ -0,0 +1,46 @@ +package main + +/* + test fyne code +*/ + +import ( + fyne "fyne.io/fyne/v2" + "fyne.io/fyne/v2/app" + "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/widget" +) + +var a fyne.App +var w fyne.Window +var w2 fyne.Window + +func fynetest() { + a = app.New() + w = a.NewWindow("Hello") + + hello := widget.NewLabel("Hello Fyne!") + w.SetContent(container.NewVBox( + hello, + widget.NewButton("Hi!", func() { + hello.SetText("Welcome :)") + bobWindow() + }), + )) + + w.Show() + + // bobWindow() + // go w.ShowAndRun() +} + +func bobWindow() { + bw := a.NewWindow("Hello bob") + bob := widget.NewLabel("bob") + + bw.SetContent(container.NewVBox( + bob, + )) + + bw.Show() +} diff --git a/main.go b/main.go index 1fe2a1a..66100f9 100644 --- a/main.go +++ b/main.go @@ -10,9 +10,6 @@ package main import ( "go.wit.com/log" "go.wit.com/toolkits/tree" - "fyne.io/fyne/v2/app" - "fyne.io/fyne/v2/container" - "fyne.io/fyne/v2/widget" ) func init() { @@ -36,27 +33,11 @@ func init() { showOptions() go simpleStdin() - fynetest() } // this must be defined for plugin's, but is never run // if you build this as a non-plugin, this will run func main() { fynetest() -} - - -func fynetest() { - a := app.New() - w := a.NewWindow("Hello") - - hello := widget.NewLabel("Hello Fyne!") - w.SetContent(container.NewVBox( - hello, - widget.NewButton("Hi!", func() { - hello.SetText("Welcome :)") - }), - )) - - w.ShowAndRun() + a.Run() } diff --git a/stdin.go b/stdin.go index fc2f2e5..df27e0a 100644 --- a/stdin.go +++ b/stdin.go @@ -55,7 +55,8 @@ func simpleStdin() { tree.ListWidgets() case "b": log.Log(NOW, "show buttons") - tree.ShowButtons() + // tree.ShowButtons() + bobWindow() case "g": me.myTree.SendToolkitLoad("gocui") case "a":