blob: d391ed453b306d8c1e5ad73c8d4192953e7adb35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package main
import (
"log"
"os"
"time"
"git.wit.org/wit/gui"
)
func main() {
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() {
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
// You can not involke the GUI from external goroutines in most cases.
func watchGUI() {
var i = 1
for {
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()")
}
|