This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
2023-01-12 21:12:43 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "os"
|
|
|
|
import "time"
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo"
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
2023-01-12 23:03:08 +00:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/layouts"
|
2023-01-12 21:12:43 +00:00
|
|
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
|
|
|
|
|
|
|
|
func main () {
|
|
|
|
tomo.Run(run)
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func run () {
|
|
|
|
window, _ := tomo.NewWindow(2, 2)
|
|
|
|
window.SetTitle("clock")
|
2023-01-12 23:03:08 +00:00
|
|
|
container := basic.NewContainer(layouts.Vertical { true, true })
|
|
|
|
window.Adopt(container)
|
2023-01-12 21:12:43 +00:00
|
|
|
label := basic.NewLabel(formatTime(), false)
|
2023-01-12 23:03:08 +00:00
|
|
|
container.Adopt(label, false)
|
2023-01-12 21:12:43 +00:00
|
|
|
window.OnClose(tomo.Stop)
|
|
|
|
window.Show()
|
|
|
|
go tick(label)
|
|
|
|
}
|
|
|
|
|
|
|
|
func formatTime () (timeString string) {
|
|
|
|
return time.Now().Format("2006-01-02 15:04:05")
|
|
|
|
}
|
|
|
|
|
|
|
|
func tick (label *basic.Label) {
|
|
|
|
for {
|
|
|
|
label.SetText(formatTime())
|
|
|
|
time.Sleep(time.Second)
|
|
|
|
}
|
|
|
|
}
|