diff --git a/.gitignore b/.gitignore index b05f7ca..66ee70b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ cloud-control-panel example-gui/example-gui example-systray/example-systray example-UI-table/example-UI-table +example-UI-table2/example-UI-table2 example-dnssecsocket/example-dnssecsocket example-table1/example-table1 diff --git a/example-UI-table2/Makefile b/example-UI-table2/Makefile new file mode 100644 index 0000000..84a5618 --- /dev/null +++ b/example-UI-table2/Makefile @@ -0,0 +1,5 @@ +run: + go run *.go + +build: + go build diff --git a/example-UI-table2/main.go b/example-UI-table2/main.go new file mode 100644 index 0000000..3d2586a --- /dev/null +++ b/example-UI-table2/main.go @@ -0,0 +1,65 @@ +package main + +import "log" +import "fmt" +import "time" + +// import "os" +// import "fmt" +// import "github.com/gookit/config" + +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) + } + + log.Println("Sleep for 2 seconds, then try to add new tabs") + time.Sleep(1 * 1000 * 1000 * 1000) + gui.AddTableTab(cloudtab, 0, "test seven", 7, parts) +}