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
|
// This creates a simple hello world window
package main
import (
"go.wit.com/gui"
"go.wit.com/lib/debugger"
"go.wit.com/lib/gadgets"
"go.wit.com/log"
)
// 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
// the widget structure for both windows
var section1 *choices
var section2 *choices
func main() {
myGui = gui.New()
myGui.LoadToolkit("andlabs")
// myGui.LoadToolkit("nocui")
myGui.Default()
helloworld()
basicWindow = makebasicWindow()
// go will sit here until the window exits
gui.Watchdog()
}
// This initializes the first window and some widgets
func helloworld() {
mainWindow = myGui.NewWindow("hello world").SetProgName("BASEWIN1")
box := mainWindow.NewBox("hbox", true)
section1 = newChoices(box)
group := box.NewGroup("interact")
group.NewButton("show basic window", func() {
basicWindow.Toggle()
})
group.NewButton("Which Computer?", func() {
tmp := section1.computers.String()
log.Println("computer =", tmp)
for i, s := range section1.computers.Strings() {
log.Println("has option", i, s)
}
})
group.NewButton("Which Color?", func() {
tmp := section1.colors.String()
log.Println("color =", tmp)
})
group.NewButton("Show apple", func() {
apple.Show()
})
group.NewButton("Hide apple", func() {
apple.Hide()
})
group.NewButton("set socks", func() {
section1.SetSocks("blue")
section2.SetSocks("green")
})
group.NewButton("show socks", func() {
log.Info("main window socks =", section1.socks.String())
log.Info("basic window socks =", section2.socks.String())
})
group.NewButton("debugger", func() {
debugger.DebugWindow(myGui)
})
}
|