Compare commits

...

5 Commits

4 changed files with 42 additions and 37 deletions

View File

@ -1,11 +1,10 @@
VERSION = $(shell git describe --tags) VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d) BUILDTIME = $(shell date +%Y.%m.%d)
all: build all: build gocui
./basicwindow
build: build: goimports vet
GO111MODULE=off go build \ GO111MODULE=off go build -v -x \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
verbose: verbose:
@ -17,25 +16,20 @@ install:
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
clean: clean:
-rm -f gadgetwindow -rm -f basicwindow go.*
# embed the toolkit plugins in the binary # embed the toolkit plugins in the binary
embed: embed:
-rm resources/*.so -rm resources/*.so
touch resources/blank.so touch resources/blank.so
cp -a ~/go/src/go.wit.com/toolkits/*.so resources/ cp -a ~/go/src/go.wit.com/toolkits/*/*.so resources/
gocui: gocui:
./basicwindow --gui gocui ./basicwindow --gui gocui
goimports: goimports:
goimports -w *.go goimports -w *.go
# // to globally reset paths:
# // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" .
redomod:
rm -f go.*
goimports -w *.go
GO111MODULE= go mod init
GO111MODULE= go mod tidy
vet:
@GO111MODULE=off go vet
@echo this go binary package builds okay

16
argv.go
View File

@ -1,11 +1,5 @@
package main package main
import (
"os"
"github.com/alexflint/go-arg"
)
/* /*
this parses the command line arguements this parses the command line arguements
this enables command line options from other packages like 'gui' and 'log' this enables command line options from other packages like 'gui' and 'log'
@ -23,16 +17,6 @@ This basicwindow example demonstrates multiple windows
` `
} }
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 { func (args) Version() string {
return "basicwindow " + VERSION return "basicwindow " + VERSION
} }

24
main.go
View File

@ -1,17 +1,18 @@
package main package main
import ( import (
"os"
"go.wit.com/dev/alexflint/arg"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/prep"
"go.wit.com/log" "go.wit.com/log"
) )
// sent via -ldflags // sent via -ldflags
var VERSION string var VERSION string
// This is the beginning of the binary tree of widgets
var myGui *gui.Node
// this is the primary window. If you close it, the program will exit // this is the primary window. If you close it, the program will exit
var mainWindow *gui.Node var mainWindow *gui.Node
@ -25,19 +26,28 @@ var computers *gui.Node
var colors *gui.Node var colors *gui.Node
func main() { func main() {
myGui = gui.New().Default() me := new(mainType)
// myGui.LoadToolkit("nocui") me.myGui = prep.Gui() // prepares the GUI package for go-args
me.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 == "?" {
me.pp.WriteHelp(os.Stdout)
os.Exit(0)
}
me.myGui.Start() // loads the GUI toolkit (GO Plugins)
helloworld() helloworld()
basicWindow = makebasicWindow() basicWindow = makebasicWindow()
// go will sit here until the window exits // use this or make a loop to do something
gui.Watchdog() gui.Watchdog()
} }
// This initializes the first window and some widgets // This initializes the first window and some widgets
func helloworld() { func helloworld() {
mainWindow = myGui.NewWindow("primary helloworld window").SetProgName("BASEWIN1") mainWindow = gui.RawWindow("primary helloworld window").SetProgName("BASEWIN1")
box := mainWindow.NewBox("vbox", false) box := mainWindow.NewBox("vbox", false)
group := box.NewGroup("choices") group := box.NewGroup("choices")

17
structs.go Normal file
View File

@ -0,0 +1,17 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/gui/prep"
)
var me *mainType
// this app's variables
type mainType struct {
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
myGui *prep.GuiPrep // the gui toolkit handle
}