2022-10-11 11:25:46 -05:00
|
|
|
// This creates a simple hello world window
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-10-16 08:07:13 -05:00
|
|
|
"os"
|
|
|
|
"log"
|
2022-10-11 11:25:46 -05:00
|
|
|
"git.wit.org/wit/gui"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2022-10-19 13:23:22 -05:00
|
|
|
f, err := os.OpenFile("/tmp/guilogfile", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("error opening file: %v", err)
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
log.SetOutput(f)
|
|
|
|
log.Println("This is a test log entry")
|
|
|
|
|
2022-10-11 11:25:46 -05:00
|
|
|
gui.Main(initGUI)
|
|
|
|
}
|
|
|
|
|
|
|
|
// This initializes the first window
|
|
|
|
func initGUI() {
|
2022-10-19 13:23:22 -05:00
|
|
|
var w *gui.Node
|
2022-10-11 11:25:46 -05:00
|
|
|
gui.Config.Title = "Hello World golang wit/gui Window"
|
|
|
|
gui.Config.Width = 640
|
|
|
|
gui.Config.Height = 480
|
2022-10-16 08:07:13 -05:00
|
|
|
gui.Config.Exit = myDefaultExit
|
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
w = gui.NewWindow()
|
|
|
|
w.Dump()
|
|
|
|
addDemoTab(w, "A Simple Tab Demo")
|
|
|
|
addDemoTab(w, "A Second Tab")
|
2022-10-11 11:25:46 -05:00
|
|
|
}
|
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
func addDemoTab(window *gui.Node, title string) {
|
|
|
|
var newNode, g *gui.Node
|
|
|
|
|
2022-10-20 06:55:42 -05:00
|
|
|
newNode = window.NewTab(title)
|
2022-10-19 13:23:22 -05:00
|
|
|
log.Println("addDemoTab() newNode.Dump")
|
|
|
|
log.Println("addDemoTab() newNode.Dump")
|
|
|
|
log.Println("addDemoTab() newNode.Dump")
|
|
|
|
log.Println("addDemoTab() newNode.Dump")
|
|
|
|
newNode.Dump()
|
|
|
|
|
|
|
|
g = newNode.NewGroup("group 1")
|
|
|
|
log.Println("addDemoTab() g.Dump")
|
|
|
|
log.Println("addDemoTab() g.Dump")
|
|
|
|
log.Println("addDemoTab() g.Dump")
|
|
|
|
log.Println("addDemoTab() g.Dump")
|
|
|
|
g.Dump()
|
|
|
|
// os.Exit(0)
|
2022-10-20 06:55:42 -05:00
|
|
|
dd := g.NewDropdown("demoCombo2")
|
|
|
|
dd.AddDropdown("more 1")
|
|
|
|
dd.AddDropdown("more 2")
|
|
|
|
dd.AddDropdown("more 3")
|
2022-10-11 11:25:46 -05:00
|
|
|
}
|
2022-10-16 08:07:13 -05:00
|
|
|
|
|
|
|
func myDefaultExit(n *gui.Node) {
|
|
|
|
log.Println("You can Do exit() things here")
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|