show & hide tests

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-19 00:34:15 -06:00
parent cdeb6042fc
commit 99de2790d5
4 changed files with 59 additions and 30 deletions

View File

@ -2,23 +2,39 @@
package main
import (
"go.wit.com/log"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/log"
)
var apple *gui.Node
// This initializes the first window, a group and a button
func makebasicWindow() *gadgets.BasicWindow {
log.Warn("start basicWindow")
basicWindow = gadgets.NewBasicWindow(myGui, "basic window test")
basicWindow.Make()
basicWindow.StandardClose()
basicWindow.Custom = func () {
basicWindow.Custom = func() {
log.Warn("got to close")
}
box1 := basicWindow.Box()
group1 := box1.NewGroup("choices")
group1.NewButton("hello", func() {})
// basicWindow.Draw()
group1.NewButton("hide apple", func() {
apple.Hide()
})
group1.NewButton("show apple", func() {
apple.Show()
})
group1.NewButton("hide computers", func() {
computers.Hide()
})
group1.NewButton("show computers", func() {
computers.Show()
})
apple = group1.NewButton("apple", func() {
log.Info("is not a pear")
})
return basicWindow
}

4
go.mod
View File

@ -3,8 +3,8 @@ module go.wit.com/apps/basicwindow
go 1.21.4
require (
go.wit.com/gui v0.12.16
go.wit.com/lib/gadgets v0.12.10
go.wit.com/gui v0.12.17
go.wit.com/lib/gadgets v0.12.11
go.wit.com/log v0.5.5
)

8
go.sum
View File

@ -4,10 +4,10 @@ go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26
go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs=
go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek=
go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
go.wit.com/gui v0.12.16 h1:GBiPiDyzkGCxwNegehHiONmNppaqyFZv7iteLUHJ/Po=
go.wit.com/gui v0.12.16/go.mod h1:27+THr2a84GZ61KKUuN30WYnYoSsBewllUKc+fnWLto=
go.wit.com/lib/gadgets v0.12.10 h1:zYKQurwuwACir6wTmiYgUprh3AvEX/b7SmEEweLaWOY=
go.wit.com/lib/gadgets v0.12.10/go.mod h1:Hb/vSiW22hPJjTVA1mShQ6HuqQ7dHGB95WLEfZlPO3M=
go.wit.com/gui v0.12.17 h1:O7fdI8dwDA8/TfkO0RN6LCK05dDiQRTE1Zvek1Imkrc=
go.wit.com/gui v0.12.17/go.mod h1:27+THr2a84GZ61KKUuN30WYnYoSsBewllUKc+fnWLto=
go.wit.com/lib/gadgets v0.12.11 h1:IgElPe2dFQq9xOQKtAx44Icfzf3tYEPP8NAhlXNUb2A=
go.wit.com/lib/gadgets v0.12.11/go.mod h1:Hb/vSiW22hPJjTVA1mShQ6HuqQ7dHGB95WLEfZlPO3M=
go.wit.com/log v0.5.5 h1:bK3b94uVKgev4jB5wg06FnvCFBEapQICTSH2YW+CWr4=
go.wit.com/log v0.5.5/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
go.wit.com/widget v1.1.5 h1:jx5hJ2WLZJnCcvMuaLHegzpNlzwo+0kOkzsRkzRiB30=

53
main.go
View File

@ -2,9 +2,9 @@
package main
import (
"go.wit.com/log"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/log"
)
// This is the beginning of the binary tree of widgets
@ -16,6 +16,12 @@ var mainWindow *gui.Node
// this is a basic window. the user can open and close it
var basicWindow *gadgets.BasicWindow
// the computers dropdown
var computers *gui.Node
// the colors combobox
var colors *gui.Node
func main() {
myGui = gui.New().Default()
// myGui.LoadToolkit("nocui")
@ -40,38 +46,45 @@ func helloworld() {
grid.NewButton("show basic window", func() {
basicWindow.Toggle()
})
grid.NewLabel("apple")
grid.NewLabel("a label")
dd := grid.NewDropdown().SetProgName("COMPUTERS")
dd.AddText("Atari 500")
dd.AddText("Beagleboard")
dd.AddText("Unmatched Rev B")
dd.AddText("asldjf")
dd.AddText("asdjf")
dd.AddText("a1jf")
dd.AddText("jf")
dd.SetText("Beagleboard")
computers = grid.NewDropdown().SetProgName("COMPUTERS")
computers.AddText("Atari 500")
computers.AddText("Beagleboard")
computers.AddText("Unmatched Rev B")
computers.AddText("asldjf")
computers.AddText("asdjf")
computers.AddText("a1jf")
computers.AddText("jf")
computers.SetText("Beagleboard")
cb := grid.NewCombobox().SetProgName("COLORS")
cb.AddText("Cyan")
cb.AddText("Magenta")
cb.AddText("Yellow")
cb.SetText("orange")
colors = grid.NewCombobox().SetProgName("COLORS")
colors.AddText("Cyan")
colors.AddText("Magenta")
colors.AddText("Yellow")
colors.SetText("orange")
grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
queryGroup := box.NewGroup("query")
queryGroup := box.NewGroup("interact")
queryGroup.NewButton("Which Computer?", func() {
tmp := dd.String()
tmp := computers.String()
log.Println("computer =", tmp)
for i, s := range dd.Strings() {
for i, s := range computers.Strings() {
log.Println("has option", i, s)
}
})
queryGroup.NewButton("Which Color?", func() {
tmp := cb.String()
tmp := colors.String()
log.Println("color =", tmp)
})
queryGroup.NewButton("Show apple", func() {
apple.Show()
})
queryGroup.NewButton("Hide apple", func() {
apple.Hide()
})
}