helloworld/main.go

65 lines
1.3 KiB
Go
Raw Permalink Normal View History

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
var VERSION string
// 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()
// go will sit here until the window exits
// 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-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")
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())
}
2024-01-16 16:37:43 -06:00
}