cleaner code and examples

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-20 13:45:01 -06:00
parent 357e34ef94
commit 30cef2f073
1 changed files with 18 additions and 9 deletions

27
main.go
View File

@ -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())
}
}