2024-01-16 16:37:43 -06:00
|
|
|
package main
|
|
|
|
|
2024-01-18 19:10:31 -06:00
|
|
|
import (
|
2024-11-07 16:54:16 -06:00
|
|
|
"embed"
|
|
|
|
|
2024-01-18 19:10:31 -06:00
|
|
|
"go.wit.com/gui"
|
2024-01-16 16:37:43 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-11-07 13:50:28 -06:00
|
|
|
// sent via -ldflags
|
2024-11-07 13:03:42 -06:00
|
|
|
var VERSION string
|
|
|
|
|
2024-01-20 13:45:01 -06:00
|
|
|
// This is the beginning of our binary tree of widgets
|
|
|
|
var myGui *gui.Node
|
2024-01-16 16:37:43 -06:00
|
|
|
|
2024-11-07 16:54:16 -06:00
|
|
|
//go:embed resources/*
|
|
|
|
var resources embed.FS
|
|
|
|
|
2024-01-16 16:37:43 -06:00
|
|
|
func main() {
|
2024-11-07 16:54:16 -06:00
|
|
|
myGui = gui.New()
|
|
|
|
myGui.InitEmbed(resources)
|
|
|
|
myGui.Default()
|
2024-01-16 16:37:43 -06:00
|
|
|
|
|
|
|
helloworld()
|
2024-01-20 13:45:01 -06:00
|
|
|
|
|
|
|
// go will sit here until the window exits
|
2024-02-12 08:27:39 -06:00
|
|
|
// intermittently, it will show toolkit statistics
|
2024-01-16 16:37:43 -06:00
|
|
|
gui.Watchdog()
|
|
|
|
}
|
|
|
|
|
|
|
|
// This initializes the first window, a group and a button
|
|
|
|
func helloworld() {
|
|
|
|
window := myGui.NewWindow("hello world")
|
|
|
|
|
2024-01-16 21:00:04 -06:00
|
|
|
box := window.NewBox("vbox", false)
|
|
|
|
group := box.NewGroup("groupy")
|
|
|
|
grid := group.NewGrid("gridiron", 2, 1)
|
2024-01-20 13:45:01 -06:00
|
|
|
|
2024-01-16 21:00:04 -06:00
|
|
|
grid.NewButton("hello", func() {
|
2024-01-16 16:37:43 -06:00
|
|
|
log.Println("world")
|
|
|
|
})
|
2024-01-16 21:00:04 -06:00
|
|
|
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")
|
|
|
|
|
2024-01-20 13:45:01 -06:00
|
|
|
color := grid.NewCombobox().SetProgName("COLORS")
|
|
|
|
color.AddText("Cyan")
|
|
|
|
color.AddText("Magenta")
|
|
|
|
color.AddText("Yellow")
|
2024-02-12 08:27:39 -06:00
|
|
|
color.Custom = func() {
|
2024-01-20 13:45:01 -06:00
|
|
|
log.Info("color is now", color.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
check := grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
|
|
|
|
check.Custom = func() {
|
|
|
|
log.Info("Checkers is now", check.Bool())
|
|
|
|
}
|
2024-01-16 16:37:43 -06:00
|
|
|
}
|