gadgetwindow/main.go

76 lines
1.6 KiB
Go

// This creates a simple hello world window
package main
import (
"go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
)
var myGui *gui.Node // This is the beginning of the binary tree of widgets
// go will sit here until the window exits
func main() {
myGui = gui.New().Default()
myGui.LoadToolkit("nocui")
helloworld()
gui.Watchdog()
}
// This initializes the first window, a group and a button
func helloworld() {
basicWin := gadgets.NewBasicWindow(myGui, "basic window test")
basicWin.Make()
basicWin.StandardExit()
box1 := basicWin.Box()
group1 := box1.NewGroup("choices")
group1.NewButton("hello", func() {})
basicWin.Draw()
window := myGui.NewWindow("hello world")
box := window.NewBox("vbox", false)
group := box.NewGroup("choices")
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")
dd.AddText("asldjf")
dd.AddText("asdjf")
dd.AddText("a1jf")
dd.AddText("jf")
dd.SetText("Beagleboard")
cb := grid.NewCombobox().SetProgName("COLORS")
cb.AddText("Cyan")
cb.AddText("Magenta")
cb.AddText("Yellow")
cb.SetText("orange")
queryGroup := box.NewGroup("query")
queryGroup.NewButton("Which Computer?", func() {
tmp := dd.String()
log.Println("computer =", tmp)
for i, s := range dd.Strings() {
log.Println("has option", i, s)
}
})
queryGroup.NewButton("Which Color?", func() {
tmp := cb.String()
log.Println("color =", tmp)
})
}