This article is intended to outline some of the basic concepts used in GTK.

Widgets

Buttons, labels, scrollbars and even windows are known as widgets in GTK. Every object you can put into a window is a widget.

Widgets have the following things associated with them:

Containers

Certain widgets are able to contain other widgets. For example, a Window widget can contain one widget, which can itself contain several more widgets, all of which may be able to contain widgets too. You can think of the widgets in a GTK project as being organised as a tree.

Containers are useful for arranging widgets in a window. If the parent widget of other widgets is hidden, then those widgets will be hidden too.

Below is a list of useful containers:

Events and Signals

Widgets can be made to perform functions when an event occurs. An example of an event is a button being clicked. When the event occurs, the widget sends out a signal, in this case the clicked signal. You can find a list of valid signals in the GTK documentation.

These signals can be received by signal handling functions which you have defined. You can connect functions in your code to certain signals, so that when the signal is received your function is run. For example, when the button is clicked, we might want to run a function which pops up a message.


Categories: CategoryPythonRecipes Parent: (unknown) | Discuss this page

PythonRecipes/GTKBasics (last edited 2011-04-09 03:56:44 by D9784B24)