nocui works

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-27 09:04:43 -06:00
parent 0bdabc5747
commit a72024107b
4 changed files with 63 additions and 3 deletions

View File

@ -2,6 +2,14 @@ all: build
reset reset
./gadgetwindow ./gadgetwindow
nocui: build
reset
./gadgetwindow --gui nocui
debugger: build
reset
./gadgetwindow --debugger
build: build:
ifeq ($(GO111MODULE),) ifeq ($(GO111MODULE),)
echo no. you must use GO111MODULE here echo no. you must use GO111MODULE here

35
args.go Normal file
View File

@ -0,0 +1,35 @@
package main
/*
this parses the command line arguements
this enables command line options from other packages like 'gui' and 'log'
*/
import (
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/debugger"
"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 NOW *log.LogFlag
func init() {
arg.MustParse(&args)
full := "go.wit.com/control-panels/dns"
short := "cpdns"
NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff")
if debugger.ArgDebug() {
log.Log(NOW, "INIT() gui debug == true")
} else {
log.Log(NOW, "INIT() gui debug == false")
}
}

View File

@ -29,7 +29,7 @@ func newChoices(parent *gui.Node) *choices {
c.grid.NewButton("hello", func() { c.grid.NewButton("hello", func() {
log.Info("world") log.Info("world")
}) })
c.grid.NewButton("show basic window", func() { c.grid.NewButton("toggle basic window", func() {
basicWindow.Toggle() basicWindow.Toggle()
}) })
c.grid.NewLabel("a label") c.grid.NewLabel("a label")
@ -75,6 +75,13 @@ func newChoices(parent *gui.Node) *choices {
} }
c.place.SetText("coffee shop") c.place.SetText("coffee shop")
c.grid.NewButton("enable animals", func() {
c.animal.Enable()
})
c.grid.NewButton("disable animals", func() {
c.animal.Disable()
})
return c return c
} }

12
main.go
View File

@ -23,8 +23,10 @@ var section1 *choices
var section2 *choices var section2 *choices
func main() { func main() {
log.SetAll(true)
log.ShowFlags()
myGui = gui.New() myGui = gui.New()
myGui.LoadToolkit("andlabs") // myGui.LoadToolkit("andlabs")
// myGui.LoadToolkit("nocui") // myGui.LoadToolkit("nocui")
myGui.Default() myGui.Default()
@ -32,6 +34,14 @@ func main() {
helloworld() helloworld()
basicWindow = makebasicWindow() basicWindow = makebasicWindow()
// run the debugger if triggered from the commandline
if debugger.ArgDebug() {
go func() {
log.Sleep(2)
debugger.DebugWindow()
}()
}
// go will sit here until the window exits // go will sit here until the window exits
gui.Watchdog() gui.Watchdog()
} }