summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-20 13:45:01 -0600
committerJeff Carr <[email protected]>2024-01-20 13:45:01 -0600
commit30cef2f0732f9a6628f04436f173504537a7ad7e (patch)
tree71702d31cf56593d69d6fb349512e11127248736
parent357e34ef94223914f26136c320612e92464a0250 (diff)
cleaner code and examples
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--main.go27
1 files changed, 18 insertions, 9 deletions
diff --git a/main.go b/main.go
index dbfd862..141b834 100644
--- a/main.go
+++ b/main.go
@@ -1,4 +1,4 @@
-// This creates a simple hello world window
+// This creates a simple helloworld window
package main
import (
@@ -6,14 +6,15 @@ import (
"go.wit.com/log"
)
-var myGui *gui.Node // This is the beginning of the binary tree of widgets
+// This is the beginning of our binary tree of widgets
+var myGui *gui.Node
-// go will sit here until the window exits
func main() {
myGui = gui.New().Default()
- myGui.LoadToolkit("nocui")
helloworld()
+
+ // go will sit here until the window exits
gui.Watchdog()
}
@@ -24,6 +25,7 @@ func helloworld() {
box := window.NewBox("vbox", false)
group := box.NewGroup("groupy")
grid := group.NewGrid("gridiron", 2, 1)
+
grid.NewButton("hello", func() {
log.Println("world")
})
@@ -41,10 +43,17 @@ func helloworld() {
dd.AddText("a1jf")
dd.AddText("jf")
- cb := grid.NewCombobox().SetProgName("COLORS")
- cb.AddText("Cyan")
- cb.AddText("Magenta")
- cb.AddText("Yellow")
+ color := grid.NewCombobox().SetProgName("COLORS")
+ color.AddText("Cyan")
+ color.AddText("Magenta")
+ color.AddText("Yellow")
+ color.Custom = func () {
+ log.Info("color is now", color.String())
+ }
+
- grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
+ check := grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
+ check.Custom = func() {
+ log.Info("Checkers is now", check.Bool())
+ }
}