1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  | 
package main
import (
	"go.wit.com/gui"
	"go.wit.com/lib/gadgets"
	"go.wit.com/lib/protobuf/argvpb"
	"go.wit.com/log"
)
// 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)
	argvpb.Init(&argv, APPNAME, BUILDTIME, VERSION) // adds shell auto-complete
	helloworld()
	basicWindow = makebasicWindow()
	// use this or make a loop to do something
	gui.Watchdog()
}
// This initializes the first window and some widgets
func helloworld() {
	if me.myGui == nil {
		panic("gui is nil")
	}
	me.myGui.Start()
	// me.gui = gui.PreInit()
	// me.myGui = fhelp.Gui()
	me.gui = me.myGui.Init()
	mainWindow = gui.RawWindow("primary helloworld window").SetProgName("BASEWIN1")
	mainWindow.Show()
	mainWindow.Custom = func() {
		log.Info("window closed")
		 argvpb.GoodExit("gui closed")
	}
	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()
	})
}
  |