diff options
| author | Jeff Carr <[email protected]> | 2022-10-11 11:59:42 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2022-10-11 11:59:42 -0500 |
| commit | 3c899365154e48aefbc0b5ee48cd089f49339cb2 (patch) | |
| tree | 13f3c0aa281d17c55306ed2e0323aa5188087e04 /cmds/gui-demo/main.go | |
| parent | 2294e22484be61a934ca8b523f4aeb40d20d6196 (diff) | |
| parent | 770fa06a18652b30db0cd4ee64e8e89d06d7de2e (diff) | |
Merge branch 'master' into develv0.3.1
Diffstat (limited to 'cmds/gui-demo/main.go')
| -rw-r--r-- | cmds/gui-demo/main.go | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/cmds/gui-demo/main.go b/cmds/gui-demo/main.go new file mode 100644 index 0000000..8eae878 --- /dev/null +++ b/cmds/gui-demo/main.go @@ -0,0 +1,68 @@ +package main + +import ( + "log" + "os" + "time" + + "git.wit.org/wit/gui" +) + +// This initializes the first window +// +// Then starts a goroutine to demonstrate how to +// inject things into the GUI +func main() { + log.Println("Starting my Control Panel") + + go gui.Main(initGUI) + + watchGUI() +} + +// This initializes the first window +func initGUI() { + gui.Config.Title = "WIT GUI Window Demo 1" + gui.Config.Width = 640 + gui.Config.Height = 480 + gui.Config.Exit = myExit + node1 := gui.NewWindow() + addDemoTab(node1, "A Simple Tab Demo") + + gui.Config.Title = "WIT GUI Window Demo 2" + gui.Config.Width = 640 + gui.Config.Height = 240 + gui.Config.Exit = myExit + node2 := gui.NewWindow() + node2.DemoAndlabsUiTab("A Simple andlabs/ui Tab Demo") +} + +// 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 == 4 { + log.Println("Opening a Debug Window via the gui.Queue()") + gui.Config.Width = 800 + gui.Config.Height = 300 + gui.Config.Exit = myDebugExit + gui.Queue(gui.DebugWindow) + } + } +} + +func myExit(n *gui.Node) { + log.Println() + log.Println("Entered myExit() on node.Name =", n.Name) + log.Println() + os.Exit(0) +} + +func myDebugExit(n *gui.Node) { + log.Println("Entered myDebugExit() on node.Name =", n.Name) + log.Println("Don't actually os.Exit()") +} |
