2024-01-16 16:37:43 -06:00
|
|
|
// This creates a simple hello world window
|
|
|
|
package main
|
|
|
|
|
2024-01-18 19:08:33 -06:00
|
|
|
import (
|
2024-01-18 19:29:02 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-18 19:08:33 -06:00
|
|
|
"go.wit.com/gui"
|
|
|
|
"go.wit.com/lib/gadgets"
|
2024-01-16 16:37:43 -06:00
|
|
|
)
|
|
|
|
|
2024-01-18 19:29:02 -06:00
|
|
|
// This is the beginning of the binary tree of widgets
|
|
|
|
var myGui *gui.Node
|
|
|
|
|
|
|
|
// this is the primary window. If you close it, the program will exit
|
|
|
|
var mainWindow *gui.Node
|
|
|
|
|
|
|
|
// this is a basic window. the user can open and close it
|
|
|
|
var basicWindow *gadgets.BasicWindow
|
2024-01-16 16:37:43 -06:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
myGui = gui.New().Default()
|
2024-01-18 21:20:07 -06:00
|
|
|
// myGui.LoadToolkit("nocui")
|
2024-01-16 16:37:43 -06:00
|
|
|
|
|
|
|
helloworld()
|
2024-01-18 21:20:07 -06:00
|
|
|
basicWindow = makebasicWindow()
|
2024-01-18 19:29:02 -06:00
|
|
|
|
|
|
|
// go will sit here until the window exits
|
2024-01-16 16:37:43 -06:00
|
|
|
gui.Watchdog()
|
|
|
|
}
|
|
|
|
|
2024-01-18 19:29:02 -06:00
|
|
|
// This initializes the first window and some widgets
|
2024-01-16 16:37:43 -06:00
|
|
|
func helloworld() {
|
2024-01-18 21:20:07 -06:00
|
|
|
mainWindow = myGui.NewWindow("hello world").SetProgName("BASEWIN1")
|
2024-01-17 20:26:07 -06:00
|
|
|
|
2024-01-18 19:29:02 -06:00
|
|
|
box := mainWindow.NewBox("vbox", false)
|
2024-01-17 01:52:54 -06:00
|
|
|
group := box.NewGroup("choices")
|
2024-01-16 21:00:04 -06:00
|
|
|
grid := group.NewGrid("gridiron", 2, 1)
|
|
|
|
grid.NewButton("hello", func() {
|
2024-01-16 16:37:43 -06:00
|
|
|
log.Println("world")
|
|
|
|
})
|
2024-01-18 19:29:02 -06:00
|
|
|
grid.NewButton("show basic window", func() {
|
2024-01-18 21:20:07 -06:00
|
|
|
basicWindow.Toggle()
|
2024-01-16 21:00:04 -06:00
|
|
|
})
|
|
|
|
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")
|
2024-01-17 03:19:59 -06:00
|
|
|
dd.SetText("Beagleboard")
|
2024-01-16 21:00:04 -06:00
|
|
|
|
|
|
|
cb := grid.NewCombobox().SetProgName("COLORS")
|
|
|
|
cb.AddText("Cyan")
|
|
|
|
cb.AddText("Magenta")
|
|
|
|
cb.AddText("Yellow")
|
2024-01-17 03:19:59 -06:00
|
|
|
cb.SetText("orange")
|
2024-01-17 01:52:54 -06:00
|
|
|
|
2024-01-18 19:29:02 -06:00
|
|
|
grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
|
|
|
|
|
2024-01-17 01:52:54 -06:00
|
|
|
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)
|
|
|
|
})
|
2024-01-16 16:37:43 -06:00
|
|
|
}
|