cloud-control-panel/example-UI-table/main.go

68 lines
1.6 KiB
Go

package main
import "log"
import "fmt"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
import "git.wit.com/wit/gui"
var cloudwin *ui.Window
var cloudtab *ui.Tab
var tabcount int
func main() {
// make this the main loop in an attempt to figure out the crashes
// do not change this until the GUI is stable
ui.Main(setupCloudUI)
}
// can not pass any args to this (?)
func setupCloudUI() {
cloudwin = ui.NewWindow("Cloud Control Panel", 640, 480, false)
cloudwin.OnClosing(func(*ui.Window) bool {
ui.Quit()
return true
})
ui.OnShouldQuit(func() bool {
cloudwin.Destroy()
return true
})
cloudtab = ui.NewTab()
cloudwin.SetChild(cloudtab)
cloudwin.SetMargined(true)
tabcount = 0
addTableTab()
// cloudtab.Append("Cloud Info", makeCloudInfoBox())
// cloudtab.SetMargined(tabcount, true)
cloudwin.Show()
}
func addTableTab() {
var parts []gui.TableColumnData
for key, foo := range []string{"BG", "TEXTCOLOR", "BUTTON", "TEXTCOLOR", "TEXTCOLOR", "TEXT", "BUTTON", "TEXT", "BUTTON"} {
log.Println(key, foo)
var b gui.TableColumnData
b.CellType = foo
b.Heading = fmt.Sprintf("heading%d", key)
parts = append(parts, b)
}
mh := gui.AddTableTab(cloudtab, 0, "test seven", 7, parts)
// set some test values as an example
mh.Rows[1].HumanData[1].Text = "jwctest1"
mh.Rows[2].HumanData[2].Text = "jwctest2"
mh.Rows[3].HumanData[3].Text = "jwctest3"
mh.Rows[3].HumanData[4].Text = "jwctest4"
mh.Rows[2].HumanData[5].Text = "jwctest5"
mh.Rows[3].HumanData[6].Text = "jwctest6"
mh.Rows[4].HumanData[7].Text = "jwctest7"
mh.Rows[5].HumanData[8].Text = "jwctest8"
}