PyGTK Tutorial

John Finlay (finlay@moeraki.com)

January 8, 2003
Table of Contents
1. Introduction
1.1. Exploring PyGTK
2. Getting Started
2.1. Hello World in GTK
2.2. Theory of Signals and Callbacks
2.3. Events
2.4. Stepping Through Hello World
3. Moving On
3.1. More on Signal Handlers
3.2. An Upgraded Hello World
4. Packing Widgets
4.1. Theory of Packing Boxes
4.2. Details of Boxes
4.3. Packing Demonstration Program
4.4. Packing Using Tables
4.5. Table Packing Example
5. Widget Overview
5.1. Widget Hierarchy
5.2. Widgets Without Windows
6. The Button Widget
6.1. Normal Buttons
6.2. Toggle Buttons
6.3. Check Buttons
6.4. Radio Buttons
7. Adjustments
7.1. Creating an Adjustment
7.2. Using Adjustments the Easy Way
7.3. Adjustment Internals
8. Range Widgets
8.1. Scrollbar Widgets
8.2. Scale Widgets
8.2.1. Creating a Scale Widget
8.2.2. Methods and Signals (well, methods, at least)
8.3. Common Range Methods
8.3.1. Setting the Update Policy
8.3.2. Getting and Setting Adjustments
8.4. Key and Mouse bindings
8.4.1. Vertical Range Widgets
8.4.2. Horizontal Range Widgets
8.5. Example
9. Miscellaneous Widgets
9.1. Labels
9.2. Arrows
9.3. The Tooltips Object
9.4. Progress Bars
9.5. Dialogs
9.6. Pixmaps
9.7. Rulers
9.8. Statusbars
9.9. Text Entries
9.10. Spin Buttons
9.11. Combo Box
9.12. Calendar
9.13. Color Selection
9.14. File Selections
10. Container Widgets
10.1. The EventBox
10.2. The Alignment widget
10.3. Fixed Container
10.4. Layout Container
10.5. Frames
10.6. Aspect Frames
10.7. Paned Window Widgets
10.8. Viewports
10.9. Scrolled Windows
10.10. Button Boxes
10.11. Toolbar
10.12. Notebooks
11. CList Widget
11.1. Creating a CList widget
11.2. Modes of operation
11.3. Working with titles
11.4. Manipulating the list itself
11.5. Adding rows to the list
11.6. Setting text and pixmaps in the cells
11.7. Storing data pointers
11.8. Working with selections
11.9. The signals that bring it together
11.10. A CList example
12. CTree Widget
12.1. Creating a CTree
12.2. Adding and Removing nodes
12.3. Setting CTree Attributes
12.4. Utilizing row data
13. Tree Widget
13.1. Creating a Tree
13.2. Adding a Subtree
13.3. Handling the Selection List
13.4. Tree Widget Internals
13.4.1. Signals
13.4.2. Methods
13.5. Tree Item Widget
13.5.1. Signals
13.5.2. Methods
13.6. Tree Example
14. Menu Widget
14.1. Manual Menu Creation
14.2. Manual Menu Example
14.3. Using ItemFactory
14.4. Item Factory Example
15. Text Widget
15.1. Creating and Configuring a Text box
15.2. Text Manipulation
15.3. Keyboard Shortcuts
15.3.1. Motion Shortcuts
15.3.2. Editing Shortcuts
15.3.3. Selection Shortcuts
15.4. A GtkText Example
16. Undocumented Widgets
16.1. Curves
16.2. Drawing Area
16.2.1 Graphics Context
16.2.2 Drawing Area Methods
16.3. Font Selection Dialog
16.4. Gamma Curve
16.5. Image
16.6. Packer
16.7. Plugs and Sockets
16.8. Preview
17. Setting Widget Attributes
17.1 Widget Flag Methods
17.2 Widget Display Methods
17.3 Widget Accelerators
17.4 Widget Name Methods
17.5 Widget Styles
18. Timeouts, IO and Idle Functions
18.1. Timeouts
18.2. Monitoring IO
18.3. Idle Functions
19. Advanced Event and Signal Handling
19.1. Signal Methods
19.1.1. Connecting and Disconnecting Signal Handlers
19.1.2. Blocking and Unblocking Signal Handlers
19.1.3. Emitting and Stopping Signals
19.2. Signal Emission and Propagation
20. Managing Selections
20.1. Overview
20.2. Retrieving the selection
20.3. Supplying the selection
21. Drag-and-drop (DND)
21.1. Overview
21.2. Properties
21.3. Methods
21.3.1. Setting up the source widget
21.3.2. Signals on the source widget:
21.3.3. Setting up a destination widget:
21.3.4. Signals on the destination widget:
22. GTK's rc Files
22.1. Functions For rc Files
22.2. GTK's rc File Format
22.3. Example rc file
23. Scribble, A Simple Example Drawing Program
23.1. Overview
23.2. Event Handling
23.3. The DrawingArea Widget, And Drawing
23.4. Adding XInput support
23.4.1. Enabling extended device information
23.4.2. Using extended device information
23.4.3. Further sophistications
24. Tips For Writing PyGTK Applications
25. Contributing
26. Credits
27. Tutorial Copyright and Permissions Notice
A. GTK Signals
A.1. GtkObject
A.2. GtkWidget
A.3. GtkData
A.4. GtkContainer
A.5. GtkCalendar
A.6. GtkEditable
A.7. GtkTipsQuery
A.8. GtkCList
A.9. GtkNotebook
A.10. GtkList
A.11. GtkMenuShell
A.12. GtkToolbar
A.13. GtkTree
A.14. GtkButton
A.15. GtkItem
A.16. GtkWindow
A.17. GtkHandleBox
A.18. GtkToggleButton
A.19. GtkMenuItem
A.20. GtkListItem
A.21. GtkTreeItem
A.22. GtkCheckMenuItem
A.23. GtkInputDialog
A.24. GtkColorSelection
A.25. GtkStatusBar
A.26. GtkCTree
A.27. GtkCurve
A.28. GtkAdjustment
B. Code Examples
B..1. scribblesimple.py
B..2. scribblexinput.py
C. List Widget
C.1. Signals
C.2. Methods
C.3. Example
C.4. List Item Widget
C.5. Signals
C.6. Methods
C.7. Example