andlabs-ui/main.go

56 lines
1.2 KiB
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!")
e := NewLineEdit("Enter text here too")
l := NewLabel("This is a label")
s0 := NewStack(Vertical, b, c, cb1, cb2, e, l)
lb := NewListbox(true, "Select One", "Or More", "To Continue")
lb2 := NewListbox(false, "Select", "Only", "One", "Please")
i := 0
doAdjustments := func() {
cb1.Append("append")
cb2.InsertBefore(fmt.Sprintf("before %d", i), 1)
lb.InsertBefore(fmt.Sprintf("%d", i), 2)
lb2.Append("Please")
i++
}
doAdjustments()
2014-02-14 16:31:21 -06:00
s1 := NewStack(Vertical, lb2, lb)
s := NewStack(Horizontal, s1, s0)
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:
err = w.SetTitle(fmt.Sprintf("%v | %s | %s | %s",
c.Checked(),
cb1.Selection(),
cb2.Selection(),
e.Text()))
if err != nil {
panic(err)
}
doAdjustments()
2014-02-12 10:29:20 -06:00
}
}
w.Hide()
}