diff options
| author | Jeff Carr <[email protected]> | 2022-10-19 13:23:22 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2022-10-19 13:23:22 -0500 |
| commit | f3af1f5b7ff78b3f73d7510622fc9633dec36d35 (patch) | |
| tree | e4868584d5e19942938aaa122b2e1cab377db000 /cmds/consolemouse/main.go | |
| parent | f7b1036e544238d65b0e3ad46d08075aa4177032 (diff) | |
Refactor to 'gui/toolkit/'
* add a example cmds/consolemouse
uses a console button to launch the andlabs/ui
* fix wrong return value in toolkit/NewLabel()
* redirect STDIN output to a file
* wonderful fix of Window() exit
* finally remove the ancient stupid variables x & y
* phase out struct 'box' and use 'node' instead
* better names for things: use NewFoo() and NewBar()
Diffstat (limited to 'cmds/consolemouse/main.go')
| -rw-r--r-- | cmds/consolemouse/main.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/cmds/consolemouse/main.go b/cmds/consolemouse/main.go new file mode 100644 index 0000000..44ad18d --- /dev/null +++ b/cmds/consolemouse/main.go @@ -0,0 +1,61 @@ +// This creates a simple hello world window +package main + +import ( + "os" + "log" +// "time" + "git.wit.org/wit/gui" +) + +import toolkit "git.wit.org/wit/gui/toolkit/gocui" + +var w *gui.Node + +func main() { + go gui.Main(initGUI) + + configureGogui() + startGogui() +} + +// This initializes the first window +func initGUI() { + gui.Config.Title = "Hello World golang wit/gui Window" + gui.Config.Width = 640 + gui.Config.Height = 480 + gui.Config.Exit = myExit + + w = gui.NewWindow() + w.Dump() + addDemoTab(w, "A Simple Tab Demo") + addDemoTab(w, "A Second Tab") +} + +func addDemoTab(window *gui.Node, title string) { + var newNode, g *gui.Node + + newNode = window.AddTab(title, nil) + log.Println("addDemoTab() newNode.Dump") + log.Println("addDemoTab() newNode.Dump") + log.Println("addDemoTab() newNode.Dump") + log.Println("addDemoTab() newNode.Dump") + newNode.Dump() + newNode.Toolkit.Dump() + + g = newNode.NewGroup("group 1") + log.Println("addDemoTab() g.Dump") + log.Println("addDemoTab() g.Dump") + log.Println("addDemoTab() g.Dump") + log.Println("addDemoTab() g.Dump") + g.Dump() + g.Toolkit.Dump() + // myExit(nil) + g.AddComboBox("demoCombo2", "more 1", "more 2", "more 3") +} + +func myExit(n *gui.Node) { + log.Println("You can Do exit() things here") + toolkit.Exit() + os.Exit(0) +} |
