EXAMPLE: provide a clean example

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-10-06 10:59:22 -05:00
parent 790e6f2c46
commit 02943567b1
4 changed files with 50 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.swp
gui-example/gui-example

5
gui-example/Makefile Normal file
View File

@ -0,0 +1,5 @@
run: build
~/go/bin/gui-example
build:
GO111MODULE="off" go install

43
gui-example/main.go Normal file
View File

@ -0,0 +1,43 @@
package main
import (
"log"
"os"
"time"
"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 = 1000
gui.Config.Height = 400
gui.Config.Exit = customExit
go gui.Main(initGUI)
watchGUI()
}
func initGUI() {
gui.NewWindow("jcarr start", 640, 480)
}
func watchGUI() {
var i = 1
for {
log.Println("Waiting for customExit()", i)
i += 1
time.Sleep(time.Second)
if i == 3 {
log.Println("Sending ExampleWindow to gui.Queue()")
gui.Queue(gui.ExampleWindow)
}
}
}

View File

@ -32,6 +32,7 @@ func ExampleWindow() {
window := box.Window
log.Println("box =", box)
log.Println("window =", window)
box.AddDebugTab("jcarr Debug")
window.UiWindow.Show()
}