Skip to content

A published v1.0.0 Golang module that provides a convenience wrapper around gowut

License

Notifications You must be signed in to change notification settings

ddrake12/wgowut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reference Build Status Go Report Card

Introduction

Wgowut (wrapped gowut) provides convenient wrapper functions around the package gowut.

Initialize GUI components in one line by calling a make function and passing in a wgowut.Options struct with any needed options.

Unspecified options will be left at the default setting for the gwu component. New options can/should be added but care should be taken to recognize the zero value of the option type and the gwu default, so that options can be omitted and normal behavior occurs and updates don't break existing GUIs (since defaults are respected). For examples, see the MakeTable() CellPadding and HAlign and the MakeListBox() Enable option implementations.

Disclaimer

This documentation is not intended as a replacement for the gowut/gwu documentation; in order to properly use wgowut, how to use gowut needs to be understood.

Recommended Usage

Create a struct in your application's GUI code that imports an anonymous *wgowut.GuiBuilder struct. Your struct should also be used to store components needed for inputs etc. Prefer tables over panels as it makes the code more readable and easy to understand. For the same reason, add high level components to window or top level table/panel in order and at the same time. Example code:

import (
	"github.com/ddrake12/wgowut"
	"github.com/icza/gowut/gwu"
)

type guiControl struct {
	importantTb gwu.TextBox
	importantLb gwu.ListBox
	*wgowut.GuiBuilder
}

func newGuiControl() *guiControl {
	return &guiControl{nil, nil, wgowut.NewGuiBuilder}
}

func StartGui() {
	gc := newGuiControl()
	win := gc.MakeWindow("urlExtension", "application", wgowut.Options{CellPadding: 10})
	btnTable := gc.makeBtnTable()
	inputTable := gc.makeInputTable() // Not shown, but here guiControl.importantTb and guiControl.importantLb would be created
	
	// make more stuff

	// add components to window or top level table/panel in order:
	win.Add(inputTable)
	win.Add(btnTable) // btnTable on bottom if last added component to a gwu.Window

	// start gwu server
}

func (gc *guiControl) makeBtnTable() gwu.Table {
	btnTable := gc.MakeTable(wgowut.Options{Rows: 1, Cols: 3, CellPadding: 5, HAlign: gwu.HARight})

	btn := gwu.NewButton("Start")
	btn.AddEHandlerFunc(func(e gwu.Event) {
		currentText := gc.importantTb.Text()
		selectedVal := gc.importantLb.SelectedValue()
		// do something with these values
	}, gwu.ETypeClick)

	// make two more components

	btnTable.Add(btn, 0, 0)
	// add two more components in order to cells 0,1 and 0,2

	return btnTable
}

Contributions Welcome!

This package is meant to be extended as needed to make GUI coding easier and faster. Please update the tests for any new options or methods and PR's will be checked/merged.

About

A published v1.0.0 Golang module that provides a convenience wrapper around gowut

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages