andlabs-ui/main.go

50 lines
963 B
Go
Raw Normal View History

// 11 february 2014
package main
2014-02-13 14:14:10 -06:00
import (
"fmt"
)
func main() {
w := NewWindow("Main Window", 320, 240)
w.Closing = make(chan struct{})
2014-02-12 10:29:20 -06:00
b := NewButton("Click Me")
c := NewCheckbox("Check Me")
2014-02-14 11:16:27 -06:00
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!")
2014-02-14 14:00:59 -06:00
e := NewLineEdit("Enter text here too")
2014-02-14 14:12:03 -06:00
l := NewLabel("This is a label")
s := NewStack(Vertical, b, c, cb1, cb2, e, l)
2014-02-13 16:04:57 -06:00
err := w.Open(s)
if err != nil {
panic(err)
}
2014-02-12 10:29:20 -06:00
mainloop:
for {
select {
case <-w.Closing:
break mainloop
case <-b.Clicked:
2014-02-14 11:16:27 -06:00
cs1, err := cb1.Selection()
if err != nil {
panic(err)
}
cs2, err := cb2.Selection()
if err != nil {
panic(err)
}
2014-02-14 14:00:59 -06:00
et, err := e.Text()
if err != nil {
panic(err)
}
err = w.SetTitle(fmt.Sprintf("%v | %s | %s | %s", c.Checked(), cs1, cs2, et))
if err != nil {
panic(err)
}
2014-02-12 10:29:20 -06:00
}
}
w.Hide()
}