summaryrefslogtreecommitdiff
path: root/main.go
blob: c1acfde9dce6a206ac0e0d40bf9c143a704fd703 (plain)
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
// This creates a simple hello world window
package main

import (
	"go.wit.com/log"
	"go.wit.com/gui"
	"go.wit.com/lib/gadgets"
)

// 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

func main() {
	myGui = gui.New().Default()
	myGui.LoadToolkit("nocui")

	helloworld()

	// 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")

	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() {
		makebasicWindow()
	})
	grid.NewLabel("apple")

	dd := grid.NewDropdown().SetProgName("COMPUTERS")
	dd.AddText("Atari 500")
	dd.AddText("Beagleboard")
	dd.AddText("Unmatched Rev B")
	dd.AddText("asldjf")
	dd.AddText("asdjf")
	dd.AddText("a1jf")
	dd.AddText("jf")
	dd.SetText("Beagleboard")

	cb := grid.NewCombobox().SetProgName("COLORS")
	cb.AddText("Cyan")
	cb.AddText("Magenta")
	cb.AddText("Yellow")
	cb.SetText("orange")

	grid.NewCheckbox("Checkers").SetProgName("CHECKERS")

	queryGroup := box.NewGroup("query")

	queryGroup.NewButton("Which Computer?", func() {
		tmp := dd.String()
		log.Println("computer =", tmp)
		for i, s := range dd.Strings() {
			log.Println("has option", i, s)
		}
	})

	queryGroup.NewButton("Which Color?", func() {
		tmp := cb.String()
		log.Println("color =", tmp)
	})
}