Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
Jeff Carr | 7fc97cd1e9 | |
Jeff Carr | 0a38ebfd47 | |
Jeff Carr | af99bd179c | |
Jeff Carr | 3133bb0801 | |
Jeff Carr | 1b7db666f1 | |
Jeff Carr | d6f9401f61 | |
Jeff Carr | 66694c1a09 |
39
Makefile
39
Makefile
|
@ -1,15 +1,40 @@
|
|||
all:
|
||||
go build -v -x
|
||||
VERSION = $(shell git describe --tags)
|
||||
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||
|
||||
all: build
|
||||
./helloworld
|
||||
|
||||
push:
|
||||
git add --all
|
||||
git commit -a
|
||||
git push
|
||||
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
|
||||
|
||||
redomod:
|
||||
rm -f go.*
|
||||
goimports -w *.go
|
||||
GO111MODULE= go mod init
|
||||
GO111MODULE= go mod tidy
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/alexflint/go-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
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
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
15
main.go
|
@ -1,20 +1,30 @@
|
|||
// 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().Default()
|
||||
myGui = gui.New()
|
||||
myGui.InitEmbed(resources)
|
||||
myGui.Default()
|
||||
|
||||
helloworld()
|
||||
|
||||
// go will sit here until the window exits
|
||||
// intermittently, it will show toolkit statistics
|
||||
gui.Watchdog()
|
||||
}
|
||||
|
||||
|
@ -47,7 +57,6 @@ 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())
|
||||
|
|
Loading…
Reference in New Issue