Compare commits

..

No commits in common. "guimain" and "v0.20.2" have entirely different histories.

5 changed files with 11 additions and 105 deletions

View File

@ -1,41 +1,15 @@
VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d)
all: build
all:
go build -v -x
./helloworld
build:
GO111MODULE=off go build \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
verbose:
GO111MODULE=off go build -v -x -work \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
install:
GO111MODULE=off go install \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
clean:
-rm -f gadgetwindow
-rm resources/*.so
touch resources/blank.so
# embed the toolkit plugins in the binary
embed:
-rm resources/*.so
touch resources/blank.so
-cp -a ~/go/src/go.wit.com/toolkits/*.so resources/
gocui:
./helloworld --gui gocui
goimports:
goimports -w *.go
push:
git add --all
git commit -a
git push
redomod:
rm -f go.*
goimports -w *.go
GO111MODULE= go mod init
GO111MODULE= go mod tidy
go mod edit -go=1.20

39
argv.go
View File

@ -1,39 +0,0 @@
package main
import (
"os"
"go.wit.com/dev/alexflint/arg"
)
/*
this parses the command line arguements
this enables command line options from other packages like 'gui' and 'log'
*/
var argv args
type args struct {
Demo string `arg:"positional" help:"this is just a demo"`
}
func (a args) Description() string {
return `
This helloworld example demonstrates the 'gui' plugin toolkits
`
}
func init() {
pp := arg.MustParse(&argv)
// for very new users or users unfamilar with the command line, this may help them
if argv.Demo == "version" || argv.Demo == "help" || argv.Demo == "?" {
pp.WriteHelp(os.Stdout)
os.Exit(0)
}
}
func (args) Version() string {
return "helloworld " + VERSION
}

View File

@ -1,20 +0,0 @@
package main
/*
enables GUI options and the debugger in your application
*/
import (
"go.wit.com/lib/debugger"
"go.wit.com/log"
)
func init() {
if debugger.ArgDebug() {
log.Info("cmd line --debugger == true")
go func() {
log.Sleep(2)
debugger.DebugWindow()
}()
}
}

15
main.go
View File

@ -1,30 +1,20 @@
// This creates a simple helloworld window
package main
import (
"embed"
"go.wit.com/gui"
"go.wit.com/log"
)
// sent via -ldflags
var VERSION string
// This is the beginning of our binary tree of widgets
var myGui *gui.Node
//go:embed resources/*
var resources embed.FS
func main() {
myGui = gui.New()
myGui.InitEmbed(resources)
myGui.Default()
myGui = gui.New().Default()
helloworld()
// go will sit here until the window exits
// intermittently, it will show toolkit statistics
gui.Watchdog()
}
@ -57,6 +47,7 @@ func helloworld() {
log.Info("color is now", color.String())
}
check := grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
check.Custom = func() {
log.Info("Checkers is now", check.Bool())

View File