new-gui/cmds/helloworld/main.go

65 lines
1.4 KiB
Go
Raw Normal View History

2022-10-11 11:25:46 -05:00
// This creates a simple hello world window
package main
import (
"os"
"log"
2022-10-11 11:25:46 -05:00
"git.wit.org/wit/gui"
)
func main() {
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() {
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
gui.Config.Exit = myDefaultExit
w = gui.NewWindow()
w.Dump()
addDemoTab(w, "A Simple Tab Demo")
addDemoTab(w, "A Second Tab")
2022-10-11 11:25:46 -05:00
}
func addDemoTab(window *gui.Node, title string) {
var newNode, g *gui.Node
newNode = window.NewTab(title)
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)
dd := g.NewDropdown("demoCombo2")
dd.AddDropdown("more 1")
dd.AddDropdown("more 2")
dd.AddDropdown("more 3")
2022-10-11 11:25:46 -05:00
}
func myDefaultExit(n *gui.Node) {
log.Println("You can Do exit() things here")
os.Exit(0)
}