added things to debug the toolkit code
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
de85ed65b3
commit
0949113167
5
args.go
5
args.go
|
@ -12,11 +12,8 @@ import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GadgetDisplay string `arg:"env:DISPLAY"`
|
|
||||||
// GadgetTmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
|
|
||||||
// GadgetVerboseDNS bool `arg:"--verbose" help:"debug your dns settings"`
|
|
||||||
var args struct {
|
var args struct {
|
||||||
TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
|
TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
69
choices.go
69
choices.go
|
@ -2,6 +2,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -25,7 +28,8 @@ func newChoices(parent *gui.Node) *choices {
|
||||||
var c *choices
|
var c *choices
|
||||||
c = new(choices)
|
c = new(choices)
|
||||||
c.group = parent.NewGroup("choices")
|
c.group = parent.NewGroup("choices")
|
||||||
c.grid = c.group.NewGrid("gridiron", 2, 1)
|
c.grid = c.group.NewGrid("gridiron", 8, 1)
|
||||||
|
|
||||||
c.grid.NewButton("hello", func() {
|
c.grid.NewButton("hello", func() {
|
||||||
log.Info("world")
|
log.Info("world")
|
||||||
})
|
})
|
||||||
|
@ -33,6 +37,7 @@ func newChoices(parent *gui.Node) *choices {
|
||||||
basicWindow.Toggle()
|
basicWindow.Toggle()
|
||||||
})
|
})
|
||||||
c.grid.NewLabel("a label")
|
c.grid.NewLabel("a label")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.computers = c.grid.NewDropdown().SetProgName("COMPUTERS")
|
c.computers = c.grid.NewDropdown().SetProgName("COMPUTERS")
|
||||||
c.computers.AddText("Atari 500")
|
c.computers.AddText("Atari 500")
|
||||||
|
@ -42,25 +47,75 @@ func newChoices(parent *gui.Node) *choices {
|
||||||
c.computers.Custom = func() {
|
c.computers.Custom = func() {
|
||||||
log.Info("You changed the computer to:", c.computers.String())
|
log.Info("You changed the computer to:", c.computers.String())
|
||||||
}
|
}
|
||||||
|
c.grid.NewButton("modify dropdown state", func() {
|
||||||
|
c.computers.AddText("Irix")
|
||||||
|
c.computers.AddText("Macintosh Plus")
|
||||||
|
c.computers.SetText("Irix")
|
||||||
|
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
// Generate a random number between 0 and 25
|
||||||
|
randomNum := rand.Intn(8) // 26 because Intn is [0, n)
|
||||||
|
// Convert to a corresponding uppercase letter
|
||||||
|
randomLetter := rune('A' + randomNum)
|
||||||
|
c.computers.AddText("WIT " + string(randomLetter))
|
||||||
|
c.showState()
|
||||||
|
})
|
||||||
|
c.grid.NewButton("toggle", func() {
|
||||||
|
if c.computers.Hidden() {
|
||||||
|
c.computers.Show()
|
||||||
|
} else {
|
||||||
|
c.computers.Hide()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
c.grid.NewButton("dropdown state", func() {
|
||||||
|
c.showState()
|
||||||
|
})
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.colors = c.grid.NewCombobox().SetProgName("COLORS")
|
c.colors = c.grid.NewCombobox().SetProgName("COLORS")
|
||||||
c.colors.AddText("Cyan")
|
c.colors.AddText("Cyan")
|
||||||
c.colors.AddText("Magenta")
|
c.colors.AddText("Magenta")
|
||||||
c.colors.AddText("Yellow")
|
c.colors.AddText("Yellow")
|
||||||
c.colors.SetText("orange")
|
c.colors.SetText("orange")
|
||||||
|
c.grid.NewButton("modify combobox state", func() {
|
||||||
|
c.colors.AddText("Red")
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
// Generate a random number between 0 and 25
|
||||||
|
randomNum := rand.Intn(26) // 26 because Intn is [0, n)
|
||||||
|
// Convert to a corresponding uppercase letter
|
||||||
|
randomLetter := rune('A' + randomNum)
|
||||||
|
c.colors.AddText("Yellow " + string(randomLetter))
|
||||||
|
|
||||||
|
c.colors.SetText("blue")
|
||||||
|
log.Info("color value =", c.colors.String())
|
||||||
|
})
|
||||||
|
c.grid.NewButton("toggle", func() {
|
||||||
|
if c.colors.Hidden() {
|
||||||
|
c.colors.Show()
|
||||||
|
} else {
|
||||||
|
c.colors.Hide()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
c.grid.NewButton("show state", func() {
|
||||||
|
c.showState()
|
||||||
|
})
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.checkers = c.grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
|
c.checkers = c.grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
|
||||||
c.checkers.Custom = func() {
|
c.checkers.Custom = func() {
|
||||||
log.Info("Checkers is", c.checkers.Bool())
|
log.Info("Checkers is", c.checkers.Bool())
|
||||||
}
|
}
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.socks = gadgets.NewOneLiner(c.grid, "two for one")
|
c.socks = gadgets.NewOneLiner(c.grid, "two for one")
|
||||||
c.socks.SetValue("socks")
|
c.socks.SetValue("socks")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.animal = gadgets.NewBasicCombobox(c.grid, "animals")
|
c.animal = gadgets.NewBasicCombobox(c.grid, "animals")
|
||||||
c.animal.AddText("otter")
|
c.animal.AddText("otter")
|
||||||
c.animal.AddText("honey badger")
|
c.animal.AddText("honey badger")
|
||||||
c.animal.AddText("polar bear")
|
c.animal.AddText("polar bear")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.place = gadgets.NewBasicEntry(c.grid, "favorite place")
|
c.place = gadgets.NewBasicEntry(c.grid, "favorite place")
|
||||||
c.place.Custom = func() {
|
c.place.Custom = func() {
|
||||||
|
@ -73,6 +128,7 @@ func newChoices(parent *gui.Node) *choices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.place.SetText("coffee shop")
|
c.place.SetText("coffee shop")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.grid.NewButton("enable animals", func() {
|
c.grid.NewButton("enable animals", func() {
|
||||||
c.animal.Enable()
|
c.animal.Enable()
|
||||||
|
@ -91,3 +147,14 @@ func (c *choices) SetSocks(s string) *choices {
|
||||||
c.socks.SetValue(s)
|
c.socks.SetValue(s)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *choices) showState() {
|
||||||
|
log.Info("computers value =", c.computers.String())
|
||||||
|
for i, s := range c.computers.Strings() {
|
||||||
|
log.Println("computers has:", i, s)
|
||||||
|
}
|
||||||
|
log.Info("color value =", c.colors.String())
|
||||||
|
for i, s := range c.colors.Strings() {
|
||||||
|
log.Println("has option", i, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue