Table of Contents
A. License Terms


Gnocl implements GTK+ and Gnome bindings for the programming language Tcl with emphasize on ease of use, following the example of Tk. It provides commands to build quickly GTK+ / Gnome compliant applications including the canvas widget, GConf and the Gnome applet. Gnocl is split in several libraries, which can be loaded on demand.

The newest version of Gnocl can be found at

Please send feedback, suggestions, bug reports to .

The mandatory "Hello World" example looks like this:

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

package require Gnocl
set but [gnocl::button -text "Hello World" -onClicked {puts "Hello World"}]
gnocl::window -title "Hello World Example" -child $but

A more complex example which produces a GUI like the following, is explained in more detail.

package require Gnocl                                     (1)

set menu [gnocl::menu]                                    (2)
$menu add [gnocl::menuItem -text "%#New" -tooltip "Make new" \(3)
      -onClicked {puts "That's new"}]
$menu add [gnocl::menuSeparator]
$menu add [gnocl::menuItem -text "%#Quit" -onClicked exit \
      -tooltip "Quit program"]

set file [gnocl::menuItem -text "%__File" -submenu $menu]

set menu [gnocl::menu]
$menu add [gnocl::menuItem -text "%__About" \
      -tooltip "Show about dialog" \
      -onClicked {puts "Mini example (c) 2001 P.G. Baum"}]
set help [gnocl::menuItem -text "%__Help" -submenu $menu]

set toolBar [gnocl::toolBar -style both]                  (4)
$toolBar add item -text "%#Quit" -tooltip "Tooltip Quit" \(5)
      -onClicked exit
$toolBar add space
$toolBar add item -text "%#New" -tooltip "Tooltip new" \
      -onClicked {puts "That's new"}

set box [gnocl::box -orientation vertical -borderWidth 0 -spacing 0]
set win [gnocl::window -child $box -title "Test Application"](6)
$box add [gnocl::menuBar -children [list $file $help]]
$box add $toolBar 
$box add [gnocl::label -text \                            (7)
      {%<<span foreground="blue" size="large">Hello</span>\
      <span foreground="red" size="large">World</span>}] -expand 1
$box add [gnocl::statusBar] 

gnocl::mainLoop                                           (8)

Load the Gnocl package to be able to use the Gnocl commands.
Create a menu to which different menu entries are added in the following lines.
A standard New entry is created and added to the menu. The percent sign as first character of the test string gives, together with the next character, the string a special meaning (see Percent String). In this case "%#" means that "New" is used as stock item, which means that not only a standard text is used, but also if available the standard icon and a standard accelerator are added.

The string that follows the onClicked option is executed whenever the menu is clicked or its accelerator pressed.

A toolBar is created similar to the menu above. With the -type option a syle with text and icons is used.
A toolBar items is added to the toolBar. The syntax is similar to menu entries. Again a percent string is used to select a standard text and icon.
To be visible each widget must be a direct or indirect ancestor of a top level widget. The standard top level widget is window.
As main widget of the application a simple label is used. This one demonstrates another Percent String: the Markup String. It contains not only the text, but also the formatting of the text. This is very convenient and has huge advantages for internationalization of applications.
Since Gnocl is event based the GTK main loop has to be called. This function never returns. From now on the GUI reacts on user input or other events like timers and the associated callback functions are called.