diff options
Diffstat (limited to 'gui-example/main.go')
| -rw-r--r-- | gui-example/main.go | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/gui-example/main.go b/gui-example/main.go index c9e8cbd..d391ed4 100644 --- a/gui-example/main.go +++ b/gui-example/main.go @@ -8,26 +8,25 @@ import ( "git.wit.org/wit/gui" ) -func customExit(gw *gui.GuiWindow) { - log.Println("Should Exit Here") - os.Exit(0) -} - func main() { - log.Println("starting my Control Panel") - - gui.Config.Width = 800 - gui.Config.Height = 300 - gui.Config.Exit = customExit + log.Println("Starting my Control Panel") + // This initializes the first window go gui.Main(initGUI) + // This starts a goroutine to demonstrate how to + // inject things into the GUI watchGUI() } func initGUI() { - n := gui.NewWindow("WIT GUI Example Window", 640, 480) - n.AddDemoTab("A Simple Tab Demo") + gui.Config.Title = "WIT GUI Window Demo" + gui.Config.Width = 640 + gui.Config.Height = 480 + gui.Config.Exit = myExit + + node := gui.NewWindow() + node.AddDemoTab("A Simple Tab Demo") } // This demonstrates how to properly interact with the GUI @@ -36,12 +35,27 @@ func initGUI() { func watchGUI() { var i = 1 for { - log.Println("Waiting for customExit()", i) + log.Println("Waiting", i, "seconds") i += 1 time.Sleep(1 * time.Second) if i == 4 { log.Println("Opening a Debug Window via the gui.Queue()") + gui.Config.Width = 800 + gui.Config.Height = 300 + gui.Config.Exit = myDebugExit gui.Queue(gui.DebugWindow) } } } + +func myExit(n *gui.Node) { + log.Println() + log.Println("Entered myExit() on node.Name =", n.Name) + log.Println() + os.Exit(0) +} + +func myDebugExit(n *gui.Node) { + log.Println("Entered myDebugExit() on node.Name =", n.Name) + log.Println("Don't actually os.Exit()") +} |
