summaryrefslogtreecommitdiff
path: root/main.go
blob: 81e48faed25d056833c07f6273b02b3f9121315a (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
// 11 february 2014
package main

import (
	"fmt"
)

func main() {
	w := NewWindow("Main Window", 320, 240)
	w.Closing = make(chan struct{})
	b := NewButton("Click Me")
	c := NewCheckbox("Check Me")
	cb1 := NewCombobox(true, "You can edit me!", "Yes you can!", "Yes you will!")
	cb2 := NewCombobox(false, "You can't edit me!", "No you can't!", "No you won't!")
	s := NewStack(Vertical, b, c, cb1, cb2)
	err := w.Open(s)
	if err != nil {
		panic(err)
	}

mainloop:
	for {
		select {
		case <-w.Closing:
			break mainloop
		case <-b.Clicked:
			cs1, err := cb1.Selection()
			if err != nil {
				panic(err)
			}
			cs2, err := cb2.Selection()
			if err != nil {
				panic(err)
			}
			err = w.SetTitle(fmt.Sprintf("%v | %s | %s", c.Checked(), cs1, cs2))
			if err != nil {
				panic(err)
			}
		}
	}
	w.Hide()
}