new-gui/cmds/helloworld/main.go

45 lines
819 B
Go
Raw Normal View History

2022-10-11 11:25:46 -05:00
// This creates a simple hello world window
package main
import (
"os"
"log"
2022-10-11 11:25:46 -05:00
"git.wit.org/wit/gui"
)
func main() {
gui.Main(myGUI)
2022-10-11 11:25:46 -05:00
}
// This initializes the first window
func myGUI() {
var w *gui.Node
2022-10-11 11:25:46 -05:00
gui.Config.Title = "Hello World golang wit/gui Window"
gui.Config.Width = 640
gui.Config.Height = 480
gui.Config.Exit = myExit
w = gui.NewWindow()
addHelloWorld(w, "A Simple Tab")
2022-10-11 11:25:46 -05:00
}
func addHelloWorld(window *gui.Node, title string) {
var newNode, g, tb *gui.Node
newNode = window.NewTab(title)
g = newNode.NewGroup("hello")
tb = g.NewTextbox("hello world box") // when debugging, this string will be used
tb.OnChanged = func(*gui.Node) {
s := tb.GetText()
log.Println("text box =", s)
}
tb.SetText("world")
2022-10-11 11:25:46 -05:00
}
func myExit(n *gui.Node) {
log.Println("exit() here")
os.Exit(0)
}