58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"go.wit.com/gui"
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
// sent via -ldflags
|
|
var VERSION string
|
|
|
|
// 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
|
|
// intermittently, it will show toolkit statistics
|
|
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())
|
|
}
|
|
}
|