2022-11-06 12:59:24 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-11-13 08:53:03 -06:00
|
|
|
"fmt"
|
2022-11-06 12:59:24 -06:00
|
|
|
"log"
|
2022-11-13 08:53:03 -06:00
|
|
|
"time"
|
2022-11-09 08:38:50 -06:00
|
|
|
"strconv"
|
2022-11-06 12:59:24 -06:00
|
|
|
"git.wit.org/wit/gui"
|
|
|
|
)
|
|
|
|
|
2022-11-13 08:53:03 -06:00
|
|
|
var title string = "Demo Plugin Window"
|
|
|
|
|
2022-11-06 12:59:24 -06:00
|
|
|
func main() {
|
2022-11-13 08:53:03 -06:00
|
|
|
fmt.Println("\033]0;" + title + "\007")
|
|
|
|
// time.Sleep(5 * time.Second)
|
|
|
|
// var w *gui.Node
|
2022-11-06 19:57:20 -06:00
|
|
|
// this doesn't seem to work
|
|
|
|
captureSTDOUT()
|
|
|
|
|
2022-11-13 08:53:03 -06:00
|
|
|
// gui.LoadToolkit("default")
|
|
|
|
// panic("WTF gocui not happening")
|
|
|
|
// gui.LoadToolkit("gocui")
|
2023-02-25 14:05:25 -06:00
|
|
|
// gui.Init()
|
2022-11-13 08:53:03 -06:00
|
|
|
|
|
|
|
// buttonWindow()
|
|
|
|
go gui.Main(func () {
|
|
|
|
log.Println("START Main f()")
|
|
|
|
buttonWindow()
|
|
|
|
/*
|
|
|
|
log.Println("END NewWindow()")
|
|
|
|
log.Println("START NewGroup()")
|
|
|
|
g := w.NewGroup("new Group 22")
|
|
|
|
log.Println("END NewGroup()")
|
|
|
|
g.NewButton("asdjkl", func () {
|
|
|
|
log.Println("world")
|
|
|
|
})
|
|
|
|
*/
|
|
|
|
log.Println("END Main f()")
|
|
|
|
// gui.StandardExit(nil)
|
|
|
|
})
|
|
|
|
log.Println("Main() END")
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
gui.Watchdog()
|
2023-03-01 11:35:36 -06:00
|
|
|
gui.StandardExit()
|
2022-11-06 12:59:24 -06:00
|
|
|
}
|
|
|
|
|
2022-11-13 08:53:03 -06:00
|
|
|
var counter int = 5
|
2022-11-09 08:38:50 -06:00
|
|
|
|
2022-11-06 12:59:24 -06:00
|
|
|
// This creates a window
|
|
|
|
func buttonWindow() {
|
|
|
|
var w, g *gui.Node
|
2022-11-13 08:53:03 -06:00
|
|
|
gui.Config.Title = title
|
2022-11-06 12:59:24 -06:00
|
|
|
gui.Config.Width = 640
|
|
|
|
gui.Config.Height = 480
|
|
|
|
|
|
|
|
w = gui.NewWindow()
|
|
|
|
g = w.NewGroup("buttonGroup")
|
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
g.NewButton("hello", func () {
|
|
|
|
log.Println("world")
|
|
|
|
})
|
|
|
|
|
2022-11-13 08:53:03 -06:00
|
|
|
g.NewButton("NewButton()", func () {
|
|
|
|
log.Println("new foobar 2. Adding button 'foobar 3'")
|
|
|
|
name := "foobar " + strconv.Itoa(counter)
|
|
|
|
counter += 1
|
|
|
|
g.NewButton(name, func () {
|
|
|
|
log.Println("Got all the way to main() name =", name)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
g.NewButton("NewGroup()", func () {
|
|
|
|
log.Println("new foobar 2. Adding button 'foobar 3'")
|
|
|
|
name := "neat " + strconv.Itoa(counter)
|
|
|
|
counter += 1
|
|
|
|
g.NewGroup(name)
|
|
|
|
})
|
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
g.NewButton("gui.DebugWindow()", func () {
|
|
|
|
gui.DebugWindow()
|
|
|
|
})
|
|
|
|
|
2022-11-14 14:30:28 -06:00
|
|
|
g.NewButton("LoadToolkit(andlabs)", func () {
|
|
|
|
gui.LoadToolkit("andlabs")
|
2022-11-06 19:57:20 -06:00
|
|
|
})
|
|
|
|
|
2022-11-13 08:53:03 -06:00
|
|
|
g.NewButton("LoadToolkit(gocui)", func () {
|
|
|
|
gui.LoadToolkit("gocui")
|
2022-11-06 19:57:20 -06:00
|
|
|
})
|
|
|
|
|
2022-11-13 08:53:03 -06:00
|
|
|
g.NewButton("Init()", func () {
|
2023-02-25 14:05:25 -06:00
|
|
|
log.Println("gui.Init() is deprecated(?)")
|
|
|
|
//gui.Init()
|
2022-11-13 08:53:03 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
g.NewButton("Main()", func () {
|
|
|
|
go gui.Main(func () {
|
|
|
|
w := gui.NewWindow()
|
|
|
|
w.NewGroup("buttonGroup")
|
|
|
|
})
|
2022-11-06 12:59:24 -06:00
|
|
|
})
|
|
|
|
}
|