Giter VIP home page Giter VIP logo

gothic's Introduction

Tcl/Tk Go bindings.

VERSION NOTICE

Recently Tcl/Tk 8.6 were released. I use them as a default, if you still have
Tcl/Tk 8.5 use `go get -tags tcl85 github.com/nsf/gothic`.

DESCRIPTION

In its current state the bindings are a bit Tk-oriented. You can't create an
interpreter instance without Tk. In future it's likely it will be changed.

The API is very simple. In the package you have one type and one function:

type Interpreter struct
func NewInterpreter (init interface{}) *Interpreter

In order to launch an interpreter you have to call the "NewInterpreter"
function, it will make a new instance of a tcl/tk interpreter in a separate
goroutine, execute "init", block in Tk's main loop and then the function
returns a pointer to the new instance of an "Interpreter".

"init" could be a string with tcl commands that are executed before Tk's main
loop, or a function with this signature: "func (*Interpreter)". This function
gets executed the same way as the string, that is - before Tk's main loop.

Here are the methods of the "Interpreter":

func (*Interpreter) ErrorFilter(filt func(error) error)
func (*Interpreter) Eval(args ...interface{}) error
func (*Interpreter) EvalAs(out interface{}, args ...interface{}) error
func (*Interpreter) Set(name string, val interface{}) error
func (*Interpreter) UploadImage(name string, img image.Image) error
func (*Interpreter) RegisterCommand(name string, cbfunc interface{}) error
func (*Interpreter) UnregisterCommand(name string) error
func (*Interpreter) RegisterCommands(name string, val interface{}) error
func (*Interpreter) UnregisterCommands(name string) error

As it was stated before, the "Interpreter" is being executed in a separate
goroutine and each method is completely thread-safe. Also every method is
synchronous. It will queue commands for execution and wait for their
completion.

That's it. See "examples" directory it has the use cases for most of the API.

gothic's People

Contributors

nsf avatar sebastianskejoe avatar

Watchers

VITOWU avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.