99 lines
2.2 KiB
Go
99 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"go.wit.com/dev/alexflint/arg"
|
|
"go.wit.com/gui"
|
|
"go.wit.com/lib/gadgets"
|
|
"go.wit.com/lib/gui/prep"
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
// sent via -ldflags
|
|
var VERSION string
|
|
|
|
// 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
|
|
|
|
// the computers dropdown
|
|
var computers *gui.Node
|
|
|
|
// the colors combobox
|
|
var colors *gui.Node
|
|
|
|
func main() {
|
|
me := new(mainType)
|
|
me.myGui = prep.Gui() // prepares the GUI package for go-args
|
|
me.pp = arg.MustParse(&argv)
|
|
|
|
// for very new users or users unfamilar with the command line, this may help them
|
|
if argv.Demo == "version" || argv.Demo == "help" || argv.Demo == "?" {
|
|
me.pp.WriteHelp(os.Stdout)
|
|
os.Exit(0)
|
|
}
|
|
|
|
me.myGui.Start() // loads the GUI toolkit (GO Plugins)
|
|
|
|
helloworld()
|
|
basicWindow = makebasicWindow()
|
|
|
|
// use this or make a loop to do something
|
|
gui.Watchdog()
|
|
}
|
|
|
|
// This initializes the first window and some widgets
|
|
func helloworld() {
|
|
mainWindow = gui.RawWindow("primary helloworld window").SetProgName("BASEWIN1")
|
|
|
|
box := mainWindow.NewBox("vbox", false)
|
|
group := box.NewGroup("choices")
|
|
grid := group.NewGrid("gridiron", 2, 1)
|
|
grid.NewButton("hello", func() {
|
|
log.Println("world")
|
|
})
|
|
grid.NewButton("show basic window", func() {
|
|
basicWindow.Toggle()
|
|
})
|
|
grid.NewLabel("a label")
|
|
|
|
computers = grid.NewDropdown().SetProgName("COMPUTERS")
|
|
computers.AddText("Atari 500")
|
|
computers.AddText("Beagleboard")
|
|
computers.AddText("Unmatched Rev B")
|
|
computers.SetText("Beagleboard")
|
|
|
|
colors = grid.NewCombobox().SetProgName("COLORS")
|
|
colors.AddText("Cyan")
|
|
colors.AddText("Magenta")
|
|
colors.AddText("Yellow")
|
|
colors.SetText("orange")
|
|
|
|
grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
|
|
|
|
queryGroup := box.NewGroup("interact")
|
|
|
|
queryGroup.NewButton("Which Computer?", func() {
|
|
tmp := computers.String()
|
|
log.Println("computer =", tmp)
|
|
for i, s := range computers.Strings() {
|
|
log.Println("has option", i, s)
|
|
}
|
|
})
|
|
|
|
queryGroup.NewButton("Which Color?", func() {
|
|
tmp := colors.String()
|
|
log.Println("color =", tmp)
|
|
})
|
|
|
|
queryGroup.NewButton("Show apple", func() {
|
|
apple.Show()
|
|
})
|
|
queryGroup.NewButton("Hide apple", func() {
|
|
apple.Hide()
|
|
})
|
|
}
|