Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Erlang GTK binding
Erlang C Python Makefile Shell
Failed to load latest commit information.
bin sh is old, use bash instead
doc dumping autotools, wip
priv make example tweak
src v1.0.2
.gitignore add release script
AUTHORS v1.0.0
COPYING initial upload to google
ChangeLog v1.0.2
Makefile remove dialyzer no_spec flag
rebar reintroduce rebar
rebar.config harmonize rebar/makefile


  Yet Another GUI framework for Erlang - gtknode


* GUI separated from application by message passing
* distributed (application and GUI can run on different machines)
* centered around a GUI builder
* small volume of (hand-written) code
* pre-documented


  a c-node (a daemon that implements the Erlang distribution protocol)
that instantiates the GUI from a configuration file. the c-node sends
messages to the Erlang node when the user interacts with the GUI; the
Erlang application changes the state of the GUI by sending messages to
widgets in the c-node. the widgets should look like Erlang processes
with registered names. the protocol should look something like this.

CnodePid ! {aWidget,dosomething,Args}       % erlang->cNode
ApplicationPid ! {reply, Val}               % cNode->Erlang
ApplicationPid ! {signal,aWidget,eventType} % cNode->erlang

  in this example aWidget is the name given to a widget in the
configration file. it can also be thought of as the registered name of
the process implementing the widget in the c-node.
  the c-node is responsible for garbage-collecting all temporary data.


  i chose GTK2 ( as the framework. there were several reasons;

* it has an eminent GUI builder, Glade (
* it has facilities for instantiating the GUI from the Glade (XML) files
* it has good documentation
* it supports run-time type checking
* its object orientation maps well to Erlang (Obj.meth(Arg) -> Obj!{meth,[Arg]})
* the Python binding provides useful tools for code generation
* seems to be the Future (tm) in the *nix world, and runs on Windows too.

  there's three parts to the gtknode. a main loop, some support
functions for object storage and marshalling, and a whole bunch of
generated wrapper functions.
  The main loop is a pretty generic c-node that simple-mindedly
receives lists of 2-tuples;

{atom('Func'), list(boolean()|integer()|float()|atom()|string())}

  it checks that there exists a function Func and calls it, passing a
pointer to the argument list. the Func's are wrapper functions
generated from the GTK header files, and unmarshalls and type checks
the arguments before the actual GTK functions are called.
  the return value of the GTK function is sent back to the Erlang node.

  a different kind of message is sent if there is an interesting event
in the GUI (e.g. a button is pressed), where "interesting" means specified
in the Glade file.


  the c-node is started thus;
gtknode node host regname cookie cnode-name otp-version

  when started, gtknode will connect to it's application by sending a
handshake message to {node@host, regname}.
  the messsage looks like this;
{{GtkPid,handshake}, []}

  the Erlang application sends messages to the gtknode using
GtkPid. messages look like this;

list({'Gtk_function', [Args]})

  E.g., if we have a GtkButton widget, named b1, and we want to use
these functions;

const gchar* gtk_button_get_label (GtkButton *button);
void         gtk_button_set_label (GtkButton *button, const gchar *label);

  we could send this;

GtkPid ! [{'Gtk_button_set_label',[b1,"foo"]},{'Gtk_button_get_label',[b1]}].

  and we would receive this;

{{GtkPid,reply}, [{ok,void},{ok,"foo"}]}

  signals are sent from gtknode if the signal handler for a specified
signal-widget combination is set to gn_sighandler. the signals look
like this;

{{GtkPid, signal}, {atom(WidgetName),atom(SignalName)}}

  E.g., if we delete the GtkWindow named window1 we'll get this signal

{{GtkPid, signal},{window1,'GDK_DELETE'}}

  given that we've requested it, of course.


  the file src/gtknode.erl implements a controller/middleman for the
gtknode, it's quite instructive. it is recommended to use this instead of
 working directly against the c-node.
  the file examples/simple/simple.erl implements the Erlang side of a
GUI for a simple 'top' application. the GUI is specified in



  stable since 2008

Something went wrong with that request. Please try again.