This is ocaml adaptation of the GTK+ 2.0 Tutoirial.
The old tutorial and source of the examples used in this document can be found here.
Introduction
To begin our introduction to GTK, we'll start with the simplest program possible.
More on signal handlers
When creating an application, you'll want to put more than one widget inside a window.
The general steps to creating a widget in GTK are ...
You create a widget by ...
We've almost seen all there is to see of the button widget. It's pretty simple. There is however more than one way to create a button.
GTK has various widgets that can be visually adjusted by the user using the mouse or the keyboard, such as the range widgets, described in the Range Widgets section.
The category of range widgets includes the ubiquitous scrollbar widget and the less common scale widget.
Labels, arrows, tooltips, progress bars, dialog widgets, ...
EventBox, Alignment widget, fixed container, layout container, ...
There are two ways to create menus: there's the easy way, and there's the hard way. Both have their uses, but you can usually use the Itemfactory (the easy way).
These all require authors! :) Please consider contributing to our tutorial.
This describes the functions used to operate on widgets. These can be used to set style, padding, size, etc.
Timeouts and idle functions
Advanced event and signal handling
Text copy and paste is a good example of clipboard widget. You can do inter-processor communication throuth the widget.
GTK+ has a high level set of functions for doing inter-process communication via the drag-and-drop system. GTK+ can perform drag-and-drop on top of the low level Xdnd and Motif drag-and-drop protocols.
GTK has its own way of dealing with application defaults, by using rc files. These can be used to set the colors of just about any widget, and can also be used to tile pixmaps onto the background of some widgets.
In this section, we will build a simple drawing program. In the process, we will examine how to handle mouse events, how to draw in a window, and how to do drawing better by using a backing pixmap.
This document, like so much other great software out there, was created for free by volunteers. If you are at all knowledgeable about any aspect of GTK that does not already have documentation, please consider contributing to this document.
We would like to thank the following for their contributions to this text.