Frequently Asked Questions

What is Gnocl and how can it be of use to me?

Gnocl implements a Tcl binding to the Gtk+ programming libraries for the rapid development of graphical user interfaces. Also supported too are a number of bindings to key resources and packages which build upon the Gtk+ libraries such as the Gnome Applet Menu and Canvas widget. Designed to work with Tcl in a manner consistent with the general syntax and command naming conventions of Tcl, Gnocl provides a robust alternative to Tk for those developers which wish to develop applications that seamlessly integrated into the Gnome desktop environment without having to first familiarize themselves with the intricacies of the Gtk+ libraries and its dependencies. In terms of benefits, the Gnocl development mantra is 'develop once, deploy forever'. Ok, this is a bold statement but it does mean that all the repetitive tasks of setting up call-back functions, allocating buffers an and getting essential workarounds resolved to get desired features implement is already done. Besides this there are lost of 'extras' such as variable tracing for entry widget which make programming so much easier. In brief the benefits lie in spending more time on developing real applications rather that re-inventing function libraries.

What's the difference between a 'wrapper' and a 'binding'?

Gnocl is a 'binding', because it implements functionality that calls upon the resources that are in the Gtk+ libraries but using the familiar Tcl command naming convention. A 'wrapper' on the other hand, would provide access to specific function within that library. A simple example illustrates the differences. The following scripts both produce a toplevel window with a single button.

A Tcl/Gnocl script..
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require Gnocl

gnocl::window -child [gnocl::button \
    -text "Hello World" \
    -onButtonPress exit] \
    -onDelete exit
and its Python/PyGtk equivalent.
#!/usr/bin/env python

# example

import pygtk
import gtk

class HelloWorld:

def hello(self, widget, data=None):
print "Hello World"

def delete_event(self, widget, event, data=None):
print "delete event occurred"
return False

def destroy(self, widget, data=None):
print "destroy signal occurred"

def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.button = gtk.Button("Hello World")
self.button.connect("clicked", self.hello, None)
self.button.connect_object("clicked", gtk.Widget.destroy, self.window)

def main(self):

if __name__ == "__main__":
hello = HelloWorld()
In fact, its not quite right to say that these are equivalent scripts as the there is so much more there in the gnocl::window function that can be accessed immediately without any further scripting other than adding extra widget options.

goto top

Are Tk and Gnocl code compatible?

Basically, no. Whilst at first glances a Gnocl script looks pretty much like a Tk one, the construction of the binding still reflects the way in which Gtk+ works. Events handling is an example of this along with processes related to drawing widgets. Image handling too is quite different as it the rendering  of text and the ability to draw directly upon widgets. If a programmer is principally interesting in developing Linux Gnome compliant applications, then they ought to give Gnocl some serious consideration.

Is there an interactive GUI editor available for Gnocl?

Yes, Glade. Gtk+ programmers have always been aware of the imbalance between developing credible UIs and the production of application specific functionality. Glade was developed to bridge that gap. As of Gnocl Version 0.9.94, support for the loading of UI desciption files in Gnocl scripts has been made available. XML UI description files in the form of the Glade native and GtkBuilder format are both supported and can be either loaded from disk or incorporated into Tcl/Gnocl scripts for loading from a buffer (useful when used with Freewrap to produce standalone executables).

# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require Gnocl

# Create a simple layout, a widget with a button.
set gladeBuffer {<?xml version="1.0"?>
<requires-version lib="gtk+" version="2.12"/>
<widget class="GtkWindow" id="window1">
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="default_width">300</property>
<property name="default_height">100</property>
<widget class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">Close Me!</property>
<property name="response_id">0</property>

# Load the buffer.
set glade1_widgets [gnocl::glade buffer $gladeBuffer]

# Register the widgets using their glade names.
foreach item $glade1_widgets {
foreach {gnocl glade} $item {}
set $glade $gnocl

# Tweak settings, and display.
$button1 configure -onClicked {gnocl::beep}
$window1 show -onDestroy {exit}

goto top

Is Gnocl available for any other platforms other than Linux? 

Active development is only proceeding on Linux at the moment although implementations running under MS Windows and Maemo are available elsewhere. Developers seeking to port the source to other platforms are welcome to do so.

goto top

Gnocl won't compile, what can I do?

Assuming that all the necessary development resources have been installed  for your workstation and the build process begins but fails, then the most likely cause is that the Gnocl source required more recent versions of Gtk+ and the dev libraries than those currently installed on your system. If you are a first time Gnocl user, select an earlier version, perhaps 0.9.92. The makefile has a number of checks for determining which version of Gtk+ it's compiling against. There is s trade off though, the later versions of Gtk+ will tend to have more features, options and (hopefully) be more bug-free!