What is it? Contact News and Download Example Commands Screenshots and Reference Projects Gnocl Home Home |
What is it?Gnocl implements GTK+ and Gnome bindings for the programming language Tcl with special emphasize on ease of use, following the example of the Tk toolkit. 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.See here for a list of implemented, tested and documented widgets and other commands. The mandatory "Hello World" example looks like this: #!/bin/sh # 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 gnocl::mainLoop ![]() gnocl is open source (BSD license, the same as Tcl). Current Gnocl versions need GTK+ 2.0 or higher and, as compile time option, Gnome 2.0. If you still use GTK+ 1.2, please try gnocl version 0.0.10. This is the last version that was tested with GTK version 1.2.1 and Gnome version 1.2.4. The current version has been tested with GTK version 2.2.1, Gnome version 2.2.0 and Tcl version 8.4.2 under Linux. A FreeBSD port is also available. ContactPlease send comments, bug reports or requests for implementation to Peter G. Baum (peter@dr-baum.net); see here for my GnuPG key). I would also appreciate a note which project you use Gnocl for.ExampleThe following code builds a basic main window of an application with menubar, toolbar, and statusbar:package require Gnocl # create submenu for menu "File" with standard items "New" and # "Quit" (text, icon and accelerator). 'N', 'Q' respectively, # are underlined and are used as mnemonics. set menu [gnocl::menu] $menu add [gnocl::menuItem -text "%#New" -tooltip "Make new" \ -onClicked {puts "That's new"}] $menu add [gnocl::menuSeparator] $menu add [gnocl::menuItem -text "%#Quit" -onClicked exit \ -tooltip "Quit program"] # create menu "File", 'F' is underlined and used as mnemonic set file [gnocl::menuItem -text "%__File" -submenu $menu] # create menu "Help" with item "About" set menu [gnocl::menu] $menu add [gnocl::menuItem -text "%__About" \ -tooltip "Show about dialog" \ -onClicked {puts "Mini example (c) 2001 - 2003 P.G. Baum"}] set help [gnocl::menuItem -text "%__Help" -submenu $menu] # create toolbar with standard items "Quit" and "New" set toolBar [gnocl::toolBar -style both] $toolBar add item -text "%#Quit" -tooltip "Tooltip Quit" \ -onClicked exit $toolBar add space $toolBar add item -text "%#New" -tooltip "Tooltip new" \ -onClicked {puts "That's new"} # create GTK+ application with menu, toolBar, statusbar # and a label as main widget set box [gnocl::box -orientation vertical -borderWidth 0 -spacing 0] set win [gnocl::window -child $box -title "Test Application"] $box add [gnocl::menuBar -children [list $file $help]] $box add $toolBar $box add [gnocl::label -text \ {%<<span foreground="blue" size="large">Hello</span>\ <span foreground="red" size="large">World</span>}] -expand 1 $box add [gnocl::statusBar] # enter GTK+ main loop gnocl::mainLoop |