gui

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2021 License: CC-BY-3.0, Freetype, GPL-3.0-or-later Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const JS = `` /* 4415-byte string literal not displayed */

Variables

View Source
var Debug = false

Functions

func BoolData

func BoolData(v bool) *boolData

func FloatData

func FloatData(v float64) *floatData

func IntData

func IntData(v int) *intData

Types

type E

type E struct {
	// contains filtered or unexported fields
}

wraps a GUI element (button, textbox, ...), stores the dirty flag, extra attributes, lock event handler, ...

func (*E) OnEvent

func (e *E) OnEvent(f func())

Atomically set a new onevent function, which is called each time the user changes the underlying elements value.

type El

type El interface {
	// contains filtered or unexported methods
}

Underlying html element like Span, TextBox, etc.

type Page

type Page struct {
	// contains filtered or unexported fields
}

Page holds the state to serve a single GUI page to the browser

func NewPage

func NewPage(htmlTemplate string, data interface{}) *Page

NewPage constructs a Page based on an HTML template containing element tags like {{.Button}}, {{.Textbox}}, etc. data is fed to the template as additional arbitrary data, available as {{.Data}}.

func (*Page) Attr

func (d *Page) Attr(id string, k string, v interface{})

func (*Page) Button

func (d *Page) Button(id string, value interface{}, extra ...string) string

func (*Page) Checkbox

func (d *Page) Checkbox(id, text string, value bool, extra ...string) string

func (*Page) CliBox

func (d *Page) CliBox(id string, value interface{}, extra ...string) string

Command-line interface textbox where user types commands.

func (*Page) Console

func (d *Page) Console(id string, rows, cols int, value interface{}, extra ...string) string

func (*Page) Data

func (t *Page) Data() interface{}

{{.Data}} returns the extra data that was passed to NewPage

func (*Page) Element

func (d *Page) Element(id, typ, attr string, value interface{}, extra ...string) string

func (*Page) ErrorBox

func (t *Page) ErrorBox() string

{{.ErrorBox}} should be embedded in the template where errors are to be shown. CSS rules for class ErrorBox may be set, e.g., to render errors in red.

func (*Page) Img

func (d *Page) Img(id string, value interface{}, extra ...string) string

func (*Page) JS

func (d *Page) JS() string

{{.JS}} should always be embedded in the template <head>. Expands to needed JavaScript code.

func (*Page) Meter

func (d *Page) Meter(id string, min, max, value int, extra ...string) string

func (*Page) Number

func (d *Page) Number(id string, min, max, value int, extra ...string) string

func (*Page) OnAnyEvent

func (d *Page) OnAnyEvent(handler func())

OnEvent sets a handler to be called when an event happens to any of the page's HTML elements.

func (*Page) OnEvent

func (d *Page) OnEvent(id string, handler func())

OnEvent sets a handler to be called when an event happens to the HTML element with given id. The event depends on the element type: click for Button, change for TextBox, etc...

func (*Page) OnUpdate

func (d *Page) OnUpdate(f func())

Set func to be executed each time javascript polls for updates

func (*Page) Progress

func (d *Page) Progress(id string, max, value int, extra ...string) string

func (*Page) Range

func (d *Page) Range(id string, min, max, value int, extra ...string) string

func (*Page) Select

func (d *Page) Select(id string, value string, options ...string) string

func (*Page) SelectArray

func (d *Page) SelectArray(id string, value string, options []string) string

func (*Page) ServeHTTP

func (d *Page) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

func (*Page) Set

func (d *Page) Set(id string, v interface{})

func (*Page) Span

func (d *Page) Span(id string, value interface{}, extra ...string) string

{{.Span id value}} adds a piece of text ("label") to the document.

func (*Page) StringValue

func (d *Page) StringValue(id string) string

StringValue is like Value but returns the value as string, converting if necessary.

func (*Page) TextBox

func (d *Page) TextBox(id string, value interface{}, extra ...string) string

func (*Page) UpdateBox

func (t *Page) UpdateBox(text string) string

{{.UpdateBox}} adds an auto update checkbox

func (*Page) UpdateButton

func (t *Page) UpdateButton(text string) string

{{.UpdateButton}} adds a page Update button

func (*Page) Value

func (d *Page) Value(id string) interface{}

Value returns the value of the HTML element with given id. E.g.: the text in a textbox, the checked value of a checkbox, etc.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL