First Gtk program in Smalltalk
In this short tutorial I will explain how to create a simple GTK application with GNU Smalltalk. First of all we download the gtk-tools package which contains improvements for Gtk.
git clone email@example.com:gst-objectspaces/gtk-tools.git
Now we can create a first Gtk application; first we load the gtk-tools package
" Create a temporary variable "
| window |
PackageLoader fileInPackage: 'GtkTools'.
" This is a simple program that creates a window with a button and a status bar: "
" Create a new window "
window := GtkTools GtkMainWindow new.
" Set a button as the main widget, change the title and status bar "
window centralWidget: (GTK.GtkButton labeled: 'Hello World'); title: 'simple'; statusMessage: 'GTK Tutorial'; showAll. " Display me and my children "
" Launch the Gtk event loop "
Here is the result:
As you can see it is really easy to create a simple toy application with Gtk and GNU Smalltalk.
In the next episode we will see how to do a simple counter application ;-)