Jeff Carr 0482931c92 | ||
---|---|---|
.gitignore | ||
LICENSE | ||
LICENSE.PostOpen | ||
Makefile | ||
README.md | ||
action.go | ||
addText.go | ||
argv.go | ||
box.go | ||
button.go | ||
checkbox.go | ||
common.go | ||
debug.go | ||
dropdown.go | ||
flags.go | ||
grid.go | ||
group.go | ||
image.go | ||
init.go | ||
label.go | ||
mirror.go | ||
node.go | ||
plugin.go | ||
redraw.go | ||
release-logo.png | ||
separator.go | ||
setText.go | ||
slider.go | ||
spinner.go | ||
structs.go | ||
table.go | ||
textbox.go | ||
watchdog.go | ||
window.go |
README.md
gui
Package gui implements a abstraction layer for Go visual elements. TODO: check and see if go1.20 is new enough to build this
Hello World Example
// This creates a simple hello world window
package main
import (
"log"
"go.wit.com/gui"
)
var myGui *gui.Node // This is your gui object
func main() {
myGui = gui.New().Default()
helloworld()
// go will sit here until the window exits
// intermittently, it will show toolkit statistics
gui.Watchdog()
}
// This initializes the first window and 2 tabs
func helloworld() {
window := myGui.NewWindow()
group := window.NewGroup("a group of widgets")
group.NewButton("hello", func() {
log.Println("world")
})
}
Build
This will build the simple hello world example above.
go install go.wit.com/apps/helloworld@latest
A more extensive list of applications can be found on go.wit.com.
Build Toolkit Plugins
This is an example of how to build the console based toolkit plugin built against the gocui package.
GO111MODULE=off go get go.wit.com/toolkits/gocui
cd ~/go/src/go.wit.com/toolkits/gocui
go build -v -buildmode=plugin -o ~/go/lib/toolkits/gocui.so
Toolkits
The toolkits are compiled as plugins and communicate only over a channel to your application. This way, the toolkits are isolated and you don't have to care about what the user uses to display things when you write your application. Also, that allows the control panels to run in both a traditional GUI like GTK or in the console like ncurses.
There are two working toolkits. One is written to the andlabs package which provides a native linux, macos and windows. The second one is terminal window based using gocui. (There is a 3rd one using STDIN/STDOUT as a template to create new toolkit plugins.) Also, GO doesn't support plugins on Windows so the native Windows GUI awaits someone to fix that.
The next step is to allow this to work against go-gtk and go-qt.
Others potential plugins: Fyne, WASM, native macos & windows, android and hopefully also things like libSDL, faiface/pixel, slint
General Thoughts
A primary design purpose for this toolkit is to be able to develop a modern set of control panels for linux. Specifically a DNS and IPv6 control panel. Since the toolkit interface plugins are cross platform, these control panels should be able to run on the Macos and Windows also.
Definitions:
* Toolkit: the underlying GUI library (MacOS gui, Windows gui, gtk, qt, etc)
* Node: A binary tree of all the underlying widgets
Principles:
* Make code using this package simple to use
* Hide complexity internally here
* Isolate the GUI toolkit
* Widget names should try to match [Wikipedia Graphical widget]
* When in doubt, search upward in the binary tree
* It's ok to guess. Try to do something sensible.
Bugs
"The author's idea of friendly may differ to that of many other people."
-- quote from the minimalistic window manager 'evilwm'
References
Useful links and other external things which might be useful