runs. now to fix basic window os.Exit()
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b8cca8ce63
commit
05311315ce
|
@ -0,0 +1,20 @@
|
||||||
|
// This creates a simple hello world window
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This initializes the first window, a group and a button
|
||||||
|
func makebasicWindow() {
|
||||||
|
log.Warn("start basicWindow")
|
||||||
|
basicWindow = gadgets.NewBasicWindow(myGui, "basic window test")
|
||||||
|
basicWindow.Make()
|
||||||
|
basicWindow.StandardExit()
|
||||||
|
|
||||||
|
box1 := basicWindow.Box()
|
||||||
|
group1 := box1.NewGroup("choices")
|
||||||
|
group1.NewButton("hello", func() {})
|
||||||
|
basicWindow.Draw()
|
||||||
|
}
|
35
main.go
35
main.go
|
@ -2,43 +2,42 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var myGui *gui.Node // This is the beginning of the binary tree of widgets
|
// This is the beginning of the binary tree of widgets
|
||||||
|
var myGui *gui.Node
|
||||||
|
|
||||||
|
// this is the primary window. If you close it, the program will exit
|
||||||
|
var mainWindow *gui.Node
|
||||||
|
|
||||||
|
// this is a basic window. the user can open and close it
|
||||||
|
var basicWindow *gadgets.BasicWindow
|
||||||
|
|
||||||
// go will sit here until the window exits
|
|
||||||
func main() {
|
func main() {
|
||||||
myGui = gui.New().Default()
|
myGui = gui.New().Default()
|
||||||
myGui.LoadToolkit("nocui")
|
myGui.LoadToolkit("nocui")
|
||||||
|
|
||||||
helloworld()
|
helloworld()
|
||||||
|
|
||||||
|
// go will sit here until the window exits
|
||||||
gui.Watchdog()
|
gui.Watchdog()
|
||||||
}
|
}
|
||||||
|
|
||||||
// This initializes the first window, a group and a button
|
// This initializes the first window and some widgets
|
||||||
func helloworld() {
|
func helloworld() {
|
||||||
basicWin := gadgets.NewBasicWindow(myGui, "basic window test")
|
mainWindow = myGui.NewWindow("hello world")
|
||||||
basicWin.Make()
|
|
||||||
basicWin.StandardExit()
|
|
||||||
|
|
||||||
box1 := basicWin.Box()
|
box := mainWindow.NewBox("vbox", false)
|
||||||
group1 := box1.NewGroup("choices")
|
|
||||||
group1.NewButton("hello", func() {})
|
|
||||||
basicWin.Draw()
|
|
||||||
|
|
||||||
window := myGui.NewWindow("hello world")
|
|
||||||
|
|
||||||
box := window.NewBox("vbox", false)
|
|
||||||
group := box.NewGroup("choices")
|
group := box.NewGroup("choices")
|
||||||
grid := group.NewGrid("gridiron", 2, 1)
|
grid := group.NewGrid("gridiron", 2, 1)
|
||||||
grid.NewButton("hello", func() {
|
grid.NewButton("hello", func() {
|
||||||
log.Println("world")
|
log.Println("world")
|
||||||
})
|
})
|
||||||
grid.NewButton("in", func() {
|
grid.NewButton("show basic window", func() {
|
||||||
log.Println("out")
|
makebasicWindow()
|
||||||
})
|
})
|
||||||
grid.NewLabel("apple")
|
grid.NewLabel("apple")
|
||||||
|
|
||||||
|
@ -58,6 +57,8 @@ func helloworld() {
|
||||||
cb.AddText("Yellow")
|
cb.AddText("Yellow")
|
||||||
cb.SetText("orange")
|
cb.SetText("orange")
|
||||||
|
|
||||||
|
grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
|
||||||
|
|
||||||
queryGroup := box.NewGroup("query")
|
queryGroup := box.NewGroup("query")
|
||||||
|
|
||||||
queryGroup.NewButton("Which Computer?", func() {
|
queryGroup.NewButton("Which Computer?", func() {
|
||||||
|
|
Loading…
Reference in New Issue