Added a (half-working) table element
This commit is contained in:
39
examples/table/main.go
Normal file
39
examples/table/main.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
|
||||
func main () {
|
||||
tomo.Run(run)
|
||||
}
|
||||
|
||||
func run () {
|
||||
window, _ := tomo.NewWindow(2, 2)
|
||||
window.SetTitle("Table")
|
||||
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
table := containers.NewTableContainer(7, 7, true, true)
|
||||
|
||||
index := 0
|
||||
for row := 0; row < 7; row ++ {
|
||||
for column := 0; column < 7; column ++ {
|
||||
if index % 2 == 0 {
|
||||
label := elements.NewLabel (
|
||||
fmt.Sprintf("%d, %d", row, column),
|
||||
false)
|
||||
table.Set(row, column, label)
|
||||
}
|
||||
index ++
|
||||
}}
|
||||
|
||||
table.Set(2, 1, elements.NewButton("Look, I'm a button!"))
|
||||
|
||||
container.Adopt(table, true)
|
||||
window.Adopt(container)
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
}
|
||||
Reference in New Issue
Block a user