Golearn: Added Ui library testing
This commit is contained in:
parent
a27f9d2a81
commit
1a1f22299f
33
golearn/ui/main.go
Normal file
33
golearn/ui/main.go
Normal file
@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/andlabs/ui"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := ui.Main(func() {
|
||||
window := ui.NewWindow("title", 200, 100, false)
|
||||
label := ui.NewLabel("text")
|
||||
window.SetChild(label)
|
||||
window.OnClosing(func(*ui.Window) bool {
|
||||
ui.Quit()
|
||||
return true
|
||||
})
|
||||
window.Show()
|
||||
go counter(label)
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
func counter(label *ui.Label) {
|
||||
for i := 0; i < 5; i++ {
|
||||
time.Sleep(time.Second)
|
||||
ui.QueueMain(func() {
|
||||
label.SetText("number " + strconv.Itoa(i))
|
||||
})
|
||||
}
|
||||
}
|
BIN
golearn/ui/ui
Executable file
BIN
golearn/ui/ui
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user