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 package main
import ( import (
@ -6,14 +6,15 @@ import (
"go.wit.com/log" "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() { func main() {
myGui = gui.New().Default() myGui = gui.New().Default()
myGui.LoadToolkit("nocui")
helloworld() helloworld()
// go will sit here until the window exits
gui.Watchdog() gui.Watchdog()
} }
@ -24,6 +25,7 @@ func helloworld() {
box := window.NewBox("vbox", false) box := window.NewBox("vbox", false)
group := box.NewGroup("groupy") group := box.NewGroup("groupy")
grid := group.NewGrid("gridiron", 2, 1) grid := group.NewGrid("gridiron", 2, 1)
grid.NewButton("hello", func() { grid.NewButton("hello", func() {
log.Println("world") log.Println("world")
}) })
@ -41,10 +43,17 @@ func helloworld() {
dd.AddText("a1jf") dd.AddText("a1jf")
dd.AddText("jf") dd.AddText("jf")
cb := grid.NewCombobox().SetProgName("COLORS") color := grid.NewCombobox().SetProgName("COLORS")
cb.AddText("Cyan") color.AddText("Cyan")
cb.AddText("Magenta") color.AddText("Magenta")
cb.AddText("Yellow") 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())
}
} }