Cover image for Python and Tkinter programming
Title:
Python and Tkinter programming
Author:
Grayson, John E.
Personal Author:
Publication Information:
Greenwich, CT : Manning, [2000]

©2000
Physical Description:
xxiii, 658 pages : illustrations ; 24 cm
Language:
English
ISBN:
9781884777813
Format :
Book

Available:*

Library
Call Number
Material Type
Home Location
Status
Central Library QA76.73.P98 G73 2000 Adult Non-Fiction Central Closed Stacks
Searching...

On Order

Summary

Summary

This book includes full documentation for Tkinter, and also offers extensive examples for many real-world Python/Tkinter applications that will give programmers a quick start on their own projects.


Author Notes

John Grayson has a Ph.D. in molecular biology and has been putting Python to work since 1993.


Table of Contents

Prefacep. xv
Special thanksp. xvii
About the readerp. xix
About the authorp. xx
Conventionsp. xxi
About the coverp. xxii
Author onlinep. xxiii
Part I Basic conceptsp. 1
1 Pythonp. 3
1.1 Introduction to Python programming and a feature reviewp. 3
Why Python?p. 4
Where can Python be used?p. 5
1.2 Key data types: lists, tuples and dictionariesp. 5
Listsp. 5
Tuplesp. 7
Dictionariesp. 8
1.3 Classesp. 9
How do classes describe objects?p. 9
Defining classesp. 9
Neat Python trick #10p. 9
Initializing an instancep. 10
Methodsp. 10
Private and public variables and methodsp. 11
Inheritancep. 11
Multiple inheritancep. 11
Mixin classesp. 11
2 Tkinterp. 12
2.1 The Tkinter modulep. 12
What is Tkinter?p. 12
What about performance?p. 13
How do I use Tkinter?p. 13
Tkinter featuresp. 14
2.2 Mapping Tcl/Tk to Tkinterp. 14
2.3 Win32 and Unix GUIsp. 15
2.4 Tkinter class hierarchyp. 16
2.5 Tkinter widget appearancep. 17
3 Building an applicationp. 18
3.1 Calculator example: key featuresp. 21
3.2 Calculator example: source codep. 21
3.3 Examining the application structurep. 27
3.4 Extending the applicationp. 28
Part 2 Displaysp. 29
4 Tkinter widgetsp. 31
4.1 Tkinter widget tourp. 31
Toplevelp. 32
Framep. 33
Labelp. 35
Buttonp. 36
Entryp. 37
Radiobuttonp. 37
Checkbuttonp. 38
Menup. 39
Messagep. 42
Textp. 43
Canvasp. 44
Scrollbarp. 45
Listboxp. 45
Scalep. 46
4.2 Fonts and colorsp. 47
Font descriptorsp. 47
X Window System font descriptorsp. 47
Colorsp. 48
Setting application-wide default fonts and colorsp. 49
4.3 Pmw Megawidget tourp. 49
AboutDialogp. 50
Balloonp. 50
ButtonBoxp. 51
ComboBoxp. 52
ComboBoxDialogp. 53
Counterp. 54
CounterDialogp. 55
Dialogp. 56
EntryFieldp. 56
Groupp. 57
LabeledWidgetp. 58
MenuBarp. 59
MessageBarp. 59
MessageDialogp. 61
NoteBookRp. 61
NoteBookSp. 62
NoteBookp. 63
OptionMenup. 64
PanedWidgetp. 65
PromptDialogp. 66
RadioSelectp. 66
ScrolledCanvasp. 67
ScrolledFieldp. 68
ScrolledFramep. 69
ScrolledListboxp. 70
ScrolledTextp. 70
SelectionDialogp. 71
TextDialogp. 72
TimeCounterp. 73
4.4 Creating new megawidgetsp. 73
Description of the megawidgetp. 73
Optionsp. 74
Creating the megawidget classp. 74
5 Screen layoutp. 77
5.1 Introduction to layoutp. 77
Geometry managementp. 78
5.2 Packerp. 79
Using the expand optionp. 82
Using the fill optionp. 82
Using the padx and pady optionsp. 84
Using the anchor optionp. 84
Using hierarchical packingp. 84
5.3 Gridp. 86
5.4 Placerp. 90
5.5 Summaryp. 94
6 Events, bindings and callbacksp. 95
6.1 Event-driven systems: a reviewp. 95
What are events?p. 96
Event propagationp. 97
Event typesp. 97
6.2 Tkinter eventsp. 98
Eventsp. 98
6.3 Callbacksp. 102
6.4 Lambda expressionsp. 103
Avoiding lambdas altogetherp. 103
6.5 Binding events and callbacksp. 104
Bind methodsp. 104
Handling multiple bindingsp. 106
6.6 Timers and background proceduresp. 107
6.7 Dynamic callback handlersp. 107
6.8 Putting events to workp. 108
Binding widgets to dynamic datap. 108
Data verificationp. 111
Formatted (smart) widgetsp. 117
6.9 Summaryp. 119
7 Using classes, composites and special widgetsp. 120
7.1 Creating a Light Emitting Diode classp. 120
Let's try that againp. 126
What has changed?p. 129
7.2 Building a class libraryp. 129
Adding a hex nut to our class libraryp. 131
Creating a switch classp. 133
Building a Mega Widgetp. 136
7.3 Summaryp. 139
8 Dialogs and formsp. 140
8.1 Dialogsp. 141
Standard dialogsp. 141
Data entry dialogsp. 142
Single-shot formsp. 146
Tkinter variablesp. 152
8.2 A standard application frameworkp. 155
8.3 Data dictionariesp. 165
8.4 Notebooksp. 172
8.5 Browsersp. 175
8.6 Wizardsp. 184
8.7 Image mapsp. 191
8.8 Summaryp. 198
9 Panels and machinesp. 199
9.1 Building a front panelp. 199
9.2 Modularityp. 201
9.3 Implementing the front panelp. 201
9.4 GIF, BMP and overlaysp. 215
9.5 And now for a more complete examplep. 220
9.6 Virtual machines using POV-Rayp. 232
And now for something completely different... #10 The Examplep. 233
9.7 Summaryp. 236
10 Drawing blobs and rubber linesp. 237
10.1 Drawing on a canvasp. 238
Moving canvas objectsp. 243
10.2 A more complete drawing programp. 244
10.3 Scrolled canvasesp. 251
10.4 Ruler-class toolsp. 254
10.5 Stretching canvas objectsp. 258
10.6 Some finishing touchesp. 262
10.7 Speed drawingp. 271
10.8 Summaryp. 275
11 Graphs and chartsp. 276
11.1 Simple graphsp. 276
11.2 A graph widgetp. 279
Adding bargraphsp. 286
Pie chartsp. 289
11.3 3-D graphsp. 292
11.4 Strip chartsp. 296
11.5 Summaryp. 298
12 Navigationp. 300
12.1 Introduction: navigation modelsp. 300
12.2 Mouse navigationp. 301
12.3 Keyboard navigation: "mouseless navigation"p. 301
12.4 Building navigation into an applicationp. 302
12.5 Image mapsp. 305
12.6 Summaryp. 305
13 The window managerp. 306
13.1 What is a window manager?p. 306
13.2 Geometry methodsp. 307
13.3 Visibility methodsp. 308
13.4 Icon methodsp. 309
13.5 Protocol methodsp. 309
13.6 Miscellaneous wm methodsp. 310
Part 3 Putting it all together...p. 311
14 Extending Pythonp. 313
14.1 Writing a Python extensionp. 313
14.2 Building Python extensionsp. 316
Linking an extension statically in Unixp. 316
Linking an extension statically in Windowsp. 317
Building a dynamic module in Unixp. 317
Building a dynamic module in Windowsp. 318
Installing dynamic modulesp. 319
Using dynamic modulesp. 319
14.3 Using the Python API in extensionsp. 319
14.4 Building extensions in C++p. 320
14.5 Format stringsp. 321
14.6 Reference countsp. 324
14.7 Embedding Pythonp. 325
14.8 Summaryp. 328
15 Debugging applicationsp. 329
15.1 Why print statements?p. 329
15.2 A simple examplep. 330
15.3 How to debugp. 333
15.4 A Tkinter explorerp. 334
15.5 pdbp. 336
15.6 IDLEp. 336
15.7 DDDp. 337
16 Designing effective graphics applicationsp. 338
16.1 The elements of good interface designp. 339
16.2 Human factorsp. 342
Choosing fontsp. 343
Use of color in graphical user interfacesp. 344
Size considerationsp. 346
16.3 Alternative graphical user interfacesp. 346
16.4 Summaryp. 347
17 Programming for performancep. 348
17.1 Everyday speedupsp. 348
Program organizationp. 349
Using the Python optimizerp. 350
Examining codep. 350
17.2 Tkinter performancep. 350
Keep it short!p. 350
Eliminate local variablesp. 351
Keep it simplep. 351
Fast initializationp. 352
Throttling eventsp. 352
17.3 Python techniquesp. 352
Importing modulesp. 353
Concatenating stringsp. 353
Getting nested loops rightp. 354
Eliminate module referencesp. 354
Use local variablesp. 355
Using exceptionsp. 356
Using map, filter and reducep. 356
17.4 Application profilingp. 357
17.5 Python extensionsp. 359
17.6 Summaryp. 360
18 Threads and asynchronous techniquesp. 361
18.1 Threadingp. 361
Non-GUI threadsp. 362
GUI threadsp. 365
18.2 "after" processingp. 369
18.3 Summaryp. 373
19 Distributing Tkinter applicationsp. 374
19.1 General issues in distributing applicationsp. 374
19.2 Distributing Unix applicationsp. 375
19.3 Distributing Win32 applicationsp. 376
19.4 Python distribution toolsp. 379
Part 4 Appendicesp. 381
Appendix A Mapping Tk to Tkinterp. 383
Appendix B Tkinter referencep. 425
Appendix C Pmw reference: Python megawidgetsp. 542
Appendix D Building and installing Python, Tkinterp. 610
Appendix E Events and keysymsp. 617
Appendix F Cursorsp. 621
Appendix G Referencesp. 625
Indexp. 629

Google Preview