helloworld/main.go

56 lines
1.1 KiB
Go

// This creates a simple helloworld window
package main
import (
"go.wit.com/gui"
"go.wit.com/log"
)
// This is the beginning of our binary tree of widgets
var myGui *gui.Node
func main() {
myGui = gui.New().Default()
helloworld()
// go will sit here until the window exits
gui.Watchdog()
}
// This initializes the first window, a group and a button
func helloworld() {
window := myGui.NewWindow("hello world")
box := window.NewBox("vbox", false)
group := box.NewGroup("groupy")
grid := group.NewGrid("gridiron", 2, 1)
grid.NewButton("hello", func() {
log.Println("world")
})
grid.NewButton("in", func() {
log.Println("out")
})
grid.NewLabel("apple")
dd := grid.NewDropdown().SetProgName("COMPUTERS")
dd.AddText("Atari 500")
dd.AddText("Beagleboard")
dd.AddText("Unmatched Rev B")
color := grid.NewCombobox().SetProgName("COLORS")
color.AddText("Cyan")
color.AddText("Magenta")
color.AddText("Yellow")
color.Custom = func () {
log.Info("color is now", color.String())
}
check := grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
check.Custom = func() {
log.Info("Checkers is now", check.Bool())
}
}