diff --git a/basicWindow.go b/basicWindow.go new file mode 100644 index 0000000..b4f864a --- /dev/null +++ b/basicWindow.go @@ -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() +} diff --git a/main.go b/main.go index 4ff2388..c1acfde 100644 --- a/main.go +++ b/main.go @@ -2,43 +2,42 @@ package main import ( + "go.wit.com/log" "go.wit.com/gui" "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() { myGui = gui.New().Default() myGui.LoadToolkit("nocui") helloworld() + + // go will sit here until the window exits gui.Watchdog() } -// This initializes the first window, a group and a button +// This initializes the first window and some widgets func helloworld() { - basicWin := gadgets.NewBasicWindow(myGui, "basic window test") - basicWin.Make() - basicWin.StandardExit() + mainWindow = myGui.NewWindow("hello world") - box1 := basicWin.Box() - group1 := box1.NewGroup("choices") - group1.NewButton("hello", func() {}) - basicWin.Draw() - - window := myGui.NewWindow("hello world") - - box := window.NewBox("vbox", false) + box := mainWindow.NewBox("vbox", false) group := box.NewGroup("choices") grid := group.NewGrid("gridiron", 2, 1) grid.NewButton("hello", func() { log.Println("world") }) - grid.NewButton("in", func() { - log.Println("out") + grid.NewButton("show basic window", func() { + makebasicWindow() }) grid.NewLabel("apple") @@ -58,6 +57,8 @@ func helloworld() { cb.AddText("Yellow") cb.SetText("orange") + grid.NewCheckbox("Checkers").SetProgName("CHECKERS") + queryGroup := box.NewGroup("query") queryGroup.NewButton("Which Computer?", func() {