summaryrefslogtreecommitdiff
path: root/cmds/buttonplugin/main.go
blob: cd4d770712aaa7eda44a9af064a539522c3d3ac6 (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
// This is a simple example
package main

import 	(
	"log"
	"strconv"
	"git.wit.org/wit/gui"
)

func main() {
	// this doesn't seem to work
	captureSTDOUT()

	gui.Main(buttonWindow)
}

var counter int = 10

// This creates a window
func buttonWindow() {
	var w, g *gui.Node
	gui.Config.Title = "Demo Plugin Window"
	gui.Config.Width = 640
	gui.Config.Height = 480

	w = gui.NewWindow()
	g = w.NewGroup("buttonGroup")

	g.NewButton("hello", func () {
		log.Println("world")
	})

	g.NewButton("RunGreet()", func () {
		log.Println("world")
		go gui.RunGreet()
	})

	g.NewButton("gui.LookupJcarrButton()", func () {
		log.Println("gui.LookupJcarrButton()")
		gui.LookupJcarrButton()
	})

	g.NewButton("new foobar 2", func () {
		log.Println("new foobar 2. Adding button 'foobar 3'")
		name := "foobar " + strconv.Itoa(counter)
		counter += 1
		g.NewButton(name, nil)
	})
}