add debugging window
this app is used to debug the gui and toolkit packages Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
0c3ed55c33
commit
826ff28398
11
Makefile
11
Makefile
|
@ -1,25 +1,28 @@
|
||||||
all: build
|
all: build
|
||||||
reset
|
reset
|
||||||
./basicwindow
|
./gadgetwindow
|
||||||
|
|
||||||
build:
|
build:
|
||||||
ifeq ($(GO111MODULE),)
|
ifeq ($(GO111MODULE),)
|
||||||
echo no. you must use GO111MODULE here
|
echo no. you must use GO111MODULE here
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
-rm -f basicwindow
|
-rm -f gadgetwindow
|
||||||
go build -v -x
|
go build -v -x
|
||||||
endif
|
endif
|
||||||
|
|
||||||
stderr: build
|
stderr: build
|
||||||
echo "writing to /tmp/basicwindow.stderr"
|
echo "writing to /tmp/gadgetwindow.stderr"
|
||||||
./basicwindow >/tmp/basicwindow.stderr 2>&1
|
./gadgetwindow >/tmp/gadgetwindow.stderr 2>&1
|
||||||
|
|
||||||
push:
|
push:
|
||||||
git add --all
|
git add --all
|
||||||
git commit -a
|
git commit -a
|
||||||
git push
|
git push
|
||||||
|
|
||||||
|
goimports:
|
||||||
|
goimports -w *.go
|
||||||
|
|
||||||
redomod:
|
redomod:
|
||||||
rm -f go.*
|
rm -f go.*
|
||||||
goimports -w *.go
|
goimports -w *.go
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
// This creates a simple hello world window
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type choices struct {
|
||||||
|
group *gui.Node // the group
|
||||||
|
grid *gui.Node // the grid
|
||||||
|
hello *gui.Node // the hello button
|
||||||
|
computers *gui.Node
|
||||||
|
colors *gui.Node
|
||||||
|
checkers *gui.Node
|
||||||
|
|
||||||
|
socks *gadgets.OneLiner
|
||||||
|
}
|
||||||
|
|
||||||
|
// This initializes the first window and some widgets
|
||||||
|
func newChoices(parent *gui.Node) *choices {
|
||||||
|
var c *choices
|
||||||
|
c = new(choices)
|
||||||
|
c.group = parent.NewGroup("choices")
|
||||||
|
c.grid = c.group.NewGrid("gridiron", 2, 1)
|
||||||
|
c.grid.NewButton("hello", func() {
|
||||||
|
log.Info("world")
|
||||||
|
})
|
||||||
|
c.grid.NewButton("show basic window", func() {
|
||||||
|
basicWindow.Toggle()
|
||||||
|
})
|
||||||
|
c.grid.NewLabel("a label")
|
||||||
|
|
||||||
|
c.computers = c.grid.NewDropdown().SetProgName("COMPUTERS")
|
||||||
|
c.computers.AddText("Atari 500")
|
||||||
|
c.computers.AddText("Beagleboard")
|
||||||
|
c.computers.AddText("Unmatched Rev B")
|
||||||
|
c.computers.AddText("asldjf")
|
||||||
|
c.computers.AddText("asdjf")
|
||||||
|
c.computers.AddText("a1jf")
|
||||||
|
c.computers.AddText("jf")
|
||||||
|
c.computers.SetText("Beagleboard")
|
||||||
|
|
||||||
|
c.colors = c.grid.NewCombobox().SetProgName("COLORS")
|
||||||
|
c.colors.AddText("Cyan")
|
||||||
|
c.colors.AddText("Magenta")
|
||||||
|
c.colors.AddText("Yellow")
|
||||||
|
c.colors.SetText("orange")
|
||||||
|
|
||||||
|
c.checkers = c.grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
|
||||||
|
c.checkers.Custom = func() {
|
||||||
|
log.Info("Checkers is", c.checkers.Bool())
|
||||||
|
}
|
||||||
|
|
||||||
|
c.socks = gadgets.NewOneLiner(c.grid, "two for one")
|
||||||
|
c.socks.SetValue("socks")
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *choices) SetSocks(s string) *choices {
|
||||||
|
c.socks.SetValue(s)
|
||||||
|
return c
|
||||||
|
}
|
6
go.mod
6
go.mod
|
@ -1,10 +1,10 @@
|
||||||
module go.wit.com/apps/basicwindow
|
module go.wit.com/apps/gadgetwindow
|
||||||
|
|
||||||
go 1.21.4
|
go 1.21.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
go.wit.com/gui v0.12.17
|
go.wit.com/gui v0.12.18
|
||||||
go.wit.com/lib/gadgets v0.12.11
|
go.wit.com/lib/gadgets v0.12.13
|
||||||
go.wit.com/log v0.5.5
|
go.wit.com/log v0.5.5
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
8
go.sum
8
go.sum
|
@ -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/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 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek=
|
||||||
go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
|
go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
|
||||||
go.wit.com/gui v0.12.17 h1:O7fdI8dwDA8/TfkO0RN6LCK05dDiQRTE1Zvek1Imkrc=
|
go.wit.com/gui v0.12.18 h1:gFVDaJFz/Su8JgUd9Oxnb3t+FS+bzy5WJSvGoKVGYZU=
|
||||||
go.wit.com/gui v0.12.17/go.mod h1:27+THr2a84GZ61KKUuN30WYnYoSsBewllUKc+fnWLto=
|
go.wit.com/gui v0.12.18/go.mod h1:27+THr2a84GZ61KKUuN30WYnYoSsBewllUKc+fnWLto=
|
||||||
go.wit.com/lib/gadgets v0.12.11 h1:IgElPe2dFQq9xOQKtAx44Icfzf3tYEPP8NAhlXNUb2A=
|
go.wit.com/lib/gadgets v0.12.13 h1:CEPUa+rH4VjmxtaWWSqvhgGEhpIjq8zuc01FIJ62xfA=
|
||||||
go.wit.com/lib/gadgets v0.12.11/go.mod h1:Hb/vSiW22hPJjTVA1mShQ6HuqQ7dHGB95WLEfZlPO3M=
|
go.wit.com/lib/gadgets v0.12.13/go.mod h1:u+Syal5qdem7fEikOiEJdI+dO2zOybfa6vZ9ptF+bJ8=
|
||||||
go.wit.com/log v0.5.5 h1:bK3b94uVKgev4jB5wg06FnvCFBEapQICTSH2YW+CWr4=
|
go.wit.com/log v0.5.5 h1:bK3b94uVKgev4jB5wg06FnvCFBEapQICTSH2YW+CWr4=
|
||||||
go.wit.com/log v0.5.5/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
|
go.wit.com/log v0.5.5/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
|
||||||
go.wit.com/widget v1.1.5 h1:jx5hJ2WLZJnCcvMuaLHegzpNlzwo+0kOkzsRkzRiB30=
|
go.wit.com/widget v1.1.5 h1:jx5hJ2WLZJnCcvMuaLHegzpNlzwo+0kOkzsRkzRiB30=
|
||||||
|
|
78
main.go
78
main.go
|
@ -3,7 +3,9 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
|
"go.wit.com/lib/debugger"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/gui/logsettings"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,16 +18,17 @@ var mainWindow *gui.Node
|
||||||
// this is a basic window. the user can open and close it
|
// this is a basic window. the user can open and close it
|
||||||
var basicWindow *gadgets.BasicWindow
|
var basicWindow *gadgets.BasicWindow
|
||||||
|
|
||||||
// the computers dropdown
|
// the widget structure for both windows
|
||||||
var computers *gui.Node
|
var section1 *choices
|
||||||
|
var section2 *choices
|
||||||
// the colors combobox
|
|
||||||
var colors *gui.Node
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
myGui = gui.New().Default()
|
myGui = gui.New()
|
||||||
|
myGui.LoadToolkit("andlabs")
|
||||||
// myGui.LoadToolkit("nocui")
|
// myGui.LoadToolkit("nocui")
|
||||||
|
|
||||||
|
myGui.Default()
|
||||||
|
|
||||||
helloworld()
|
helloworld()
|
||||||
basicWindow = makebasicWindow()
|
basicWindow = makebasicWindow()
|
||||||
|
|
||||||
|
@ -37,54 +40,47 @@ func main() {
|
||||||
func helloworld() {
|
func helloworld() {
|
||||||
mainWindow = myGui.NewWindow("hello world").SetProgName("BASEWIN1")
|
mainWindow = myGui.NewWindow("hello world").SetProgName("BASEWIN1")
|
||||||
|
|
||||||
box := mainWindow.NewBox("vbox", false)
|
box := mainWindow.NewBox("hbox", true)
|
||||||
group := box.NewGroup("choices")
|
section1 = newChoices(box)
|
||||||
grid := group.NewGrid("gridiron", 2, 1)
|
|
||||||
grid.NewButton("hello", func() {
|
group := box.NewGroup("interact")
|
||||||
log.Println("world")
|
group.NewButton("show basic window", func() {
|
||||||
})
|
|
||||||
grid.NewButton("show basic window", func() {
|
|
||||||
basicWindow.Toggle()
|
basicWindow.Toggle()
|
||||||
})
|
})
|
||||||
grid.NewLabel("a label")
|
|
||||||
|
|
||||||
computers = grid.NewDropdown().SetProgName("COMPUTERS")
|
group.NewButton("Which Computer?", func() {
|
||||||
computers.AddText("Atari 500")
|
tmp := section1.computers.String()
|
||||||
computers.AddText("Beagleboard")
|
|
||||||
computers.AddText("Unmatched Rev B")
|
|
||||||
computers.AddText("asldjf")
|
|
||||||
computers.AddText("asdjf")
|
|
||||||
computers.AddText("a1jf")
|
|
||||||
computers.AddText("jf")
|
|
||||||
computers.SetText("Beagleboard")
|
|
||||||
|
|
||||||
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("interact")
|
|
||||||
|
|
||||||
queryGroup.NewButton("Which Computer?", func() {
|
|
||||||
tmp := computers.String()
|
|
||||||
log.Println("computer =", tmp)
|
log.Println("computer =", tmp)
|
||||||
for i, s := range computers.Strings() {
|
for i, s := range section1.computers.Strings() {
|
||||||
log.Println("has option", i, s)
|
log.Println("has option", i, s)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
queryGroup.NewButton("Which Color?", func() {
|
group.NewButton("Which Color?", func() {
|
||||||
tmp := colors.String()
|
tmp := section1.colors.String()
|
||||||
log.Println("color =", tmp)
|
log.Println("color =", tmp)
|
||||||
})
|
})
|
||||||
|
|
||||||
queryGroup.NewButton("Show apple", func() {
|
group.NewButton("Show apple", func() {
|
||||||
apple.Show()
|
apple.Show()
|
||||||
})
|
})
|
||||||
queryGroup.NewButton("Hide apple", func() {
|
group.NewButton("Hide apple", func() {
|
||||||
apple.Hide()
|
apple.Hide()
|
||||||
})
|
})
|
||||||
|
group.NewButton("set socks", func() {
|
||||||
|
section1.SetSocks("blue")
|
||||||
|
section2.SetSocks("green")
|
||||||
|
})
|
||||||
|
group.NewButton("show socks", func() {
|
||||||
|
log.Info("main window socks =", section1.socks.String())
|
||||||
|
log.Info("basic window socks =", section2.socks.String())
|
||||||
|
})
|
||||||
|
|
||||||
|
group = box.NewGroup("debug")
|
||||||
|
group.NewButton("debugger", func() {
|
||||||
|
debugger.DebugWindow()
|
||||||
|
})
|
||||||
|
group.NewButton("log options", func() {
|
||||||
|
logsettings.LogWindow()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,17 @@ var apple *gui.Node
|
||||||
func makebasicWindow() *gadgets.BasicWindow {
|
func makebasicWindow() *gadgets.BasicWindow {
|
||||||
log.Warn("start basicWindow")
|
log.Warn("start basicWindow")
|
||||||
basicWindow = gadgets.NewBasicWindow(myGui, "basic window test")
|
basicWindow = gadgets.NewBasicWindow(myGui, "basic window test")
|
||||||
|
basicWindow.Custom = func() {
|
||||||
|
log.Info("got to close")
|
||||||
|
}
|
||||||
basicWindow.Make()
|
basicWindow.Make()
|
||||||
basicWindow.StandardClose()
|
basicWindow.StandardClose()
|
||||||
basicWindow.Custom = func() {
|
|
||||||
log.Warn("got to close")
|
|
||||||
}
|
|
||||||
|
|
||||||
box1 := basicWindow.Box()
|
box1 := basicWindow.Box()
|
||||||
group1 := box1.NewGroup("choices")
|
section2 = newChoices(box1)
|
||||||
|
|
||||||
|
vbox := box1.NewBox("vbox", false)
|
||||||
|
group1 := vbox.NewGroup("controls").Horizontal() // Vertical()
|
||||||
group1.NewButton("hide apple", func() {
|
group1.NewButton("hide apple", func() {
|
||||||
apple.Hide()
|
apple.Hide()
|
||||||
})
|
})
|
||||||
|
@ -29,13 +32,14 @@ func makebasicWindow() *gadgets.BasicWindow {
|
||||||
apple.Show()
|
apple.Show()
|
||||||
})
|
})
|
||||||
group1.NewButton("hide computers", func() {
|
group1.NewButton("hide computers", func() {
|
||||||
computers.Hide()
|
section2.computers.Hide()
|
||||||
})
|
})
|
||||||
group1.NewButton("show computers", func() {
|
group1.NewButton("show computers", func() {
|
||||||
computers.Show()
|
section2.computers.Show()
|
||||||
})
|
})
|
||||||
apple = group1.NewButton("apple", func() {
|
apple = group1.NewButton("apple", func() {
|
||||||
log.Info("is not a pear")
|
log.Info("is not a pear")
|
||||||
})
|
})
|
||||||
|
|
||||||
return basicWindow
|
return basicWindow
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue