From ed382bec55be25039e4dcf020d1512139855c9bb Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 9 Nov 2022 08:38:50 -0600 Subject: cleanup of the example commands. more plugin work add a button in two plugins at the same time! added a button in andlabs/ui & gocui attempt a common widget struct between wit/gui & the plugins start handling missing plugins rename Makefile command examples remote examples used for testing filename improvements golang src code uses lowercase and _ in filenames fix crash when button click function == nil fix wrong name 'gocli' -> 'gocui' keep fighting with goreadme generated README.md Signed-off-by: Jeff Carr --- cmds/debug/Makefile | 5 +++++ cmds/debug/helloworld.go | 20 +++++++++++++++++++ cmds/debug/main.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 cmds/debug/Makefile create mode 100644 cmds/debug/helloworld.go create mode 100644 cmds/debug/main.go (limited to 'cmds/debug') diff --git a/cmds/debug/Makefile b/cmds/debug/Makefile new file mode 100644 index 0000000..25c994d --- /dev/null +++ b/cmds/debug/Makefile @@ -0,0 +1,5 @@ +run: build + ./debug + +build: + go build diff --git a/cmds/debug/helloworld.go b/cmds/debug/helloworld.go new file mode 100644 index 0000000..d0998bf --- /dev/null +++ b/cmds/debug/helloworld.go @@ -0,0 +1,20 @@ +// A simple helloworld window +package main + +import ( + "log" + "git.wit.org/wit/gui" +) + +// This creates a window +func helloworld() { + var w *gui.Node + gui.Config.Title = "helloworld golang wit/gui window" + gui.Config.Width = 400 + gui.Config.Height = 100 + + w = gui.NewWindow() + w.NewButton("hello", func () { + log.Println("world") + }) +} diff --git a/cmds/debug/main.go b/cmds/debug/main.go new file mode 100644 index 0000000..5e3a350 --- /dev/null +++ b/cmds/debug/main.go @@ -0,0 +1,52 @@ +package main + +import ( + "log" + "os" + "time" + + "git.wit.org/wit/gui" +) + +// This initializes the first window +// +// BUG: THIS PROGRAM DOESN'T EXIT PROPERLY (NOT REALLY A BUG) +// +// Then starts a goroutine to demonstrate how to +// inject things into the GUI +func main() { + log.Println("Starting my Control Panel") + + go gui.Main(helloworld) +// go gui.DemoToolkitWindow() + + watchGUI() +} + +// This demonstrates how to properly interact with the GUI +// You can not involke the GUI from external goroutines in most cases. +func watchGUI() { + var i = 1 + for { + log.Println("Waiting", i, "seconds") + i += 1 + time.Sleep(1 * time.Second) + if i == 2 { + log.Println("Opening a Debug Window via the gui.Queue()") + gui.Config.Width = 800 + gui.Config.Height = 300 + gui.Config.Exit = myExit + gui.Queue(gui.DebugWindow) + time.Sleep(1 * time.Second) + gui.Queue(gui.DebugTab) + } + } +} + +// TODO: myExit isn't getting used anymore +func myExit(n *gui.Node) { + log.Println() + log.Println("Entered myExit() on node.Name =", n.Name) + log.Println() + os.Exit(0) +} -- cgit v1.2.3