wxPython in Action

Free Download

Authors:

Edition: illustrated edition

ISBN: 9781932394627, 1-932394-62-1

Size: 6 MB (6423458 bytes)

Pages: 583/583

File format:

Language:

Publishing Year:

Category: Tags: , ,

Noel Rappin PH.D., Robin Dunn9781932394627, 1-932394-62-1

Because they are often large and complex, GUI programming tool kits can be hard to use. wxPython is a combination of the Python programming language and the wxWidgets toolkit, which allows programmers to create programs with a robust, highly functional graphical user interface, simply and easily. wxPython combines the power of an exceptionally complete user interface toolkit with an exceptionally flexible programming language. The result is a toolkit that is unique in the ease with which complex applications can be built and maintained.
“wxPython in Action” is a complete guide to the wxPython toolkit, containing a tutorial for getting started, a guide to best practices, and a reference to wxPython’s extensive widget set. After an easy introduction to wxPython concepts and programming practices, the book takes an in-depth tour of when and how to use the bountiful collection of widgets offered by wxPython. All features are illustrated with useful code examples and reference tables are included for handy lookup of an object’s properties, methods, and events. The book enables developers to learn wxPython quickly and remains a valuable resource for futurework.

Table of contents :
wxPython in Action……Page 1
contents……Page 10
preface……Page 20
acknowledgments……Page 23
Who should read this book?……Page 25
How this book is organized……Page 26
about the title……Page 30
about the cover illustration……Page 31
Part 1 – Introduction to wxPython……Page 32
Welcome to wxPython……Page 34
1.1 Getting started with wxPython……Page 36
1.2 Creating the bare minimum wxPython program……Page 38
1.2.1 Importing wxPython……Page 40
1.2.2 Working with applications and frames……Page 42
1.3 Extending the bare-minimum wxPython program……Page 43
1.4 Creating the final hello.py program……Page 46
1.5 What can wxPython do?……Page 48
1.6.1 Python programmers……Page 50
1.6.3 New users……Page 51
1.7.1 The Python language……Page 52
1.7.2 The wxWidgets toolkit……Page 53
1.7.3 Putting it together: the wxPython toolkit……Page 56
1.8 Summary……Page 58
Giving your wxPython program a solid foundation……Page 60
2.1 What do I need to know about the required objects?……Page 61
2.2.1 Creating a wx.App subclass……Page 62
2.2.2 Understanding the application object lifecycle……Page 65
2.3.1 Redirecting output……Page 66
2.3.2 Modifying the default redirect behavior……Page 68
2.4.1 Managing a normal shutdown……Page 69
2.5 How do I create and use the top-level window object?……Page 70
2.5.1 Working with wx.Frame……Page 71
2.5.2 Working with wxPython IDs……Page 73
2.5.3 Working with wx.Size and wx.Point……Page 74
2.5.4 Working with wx.Frame styles……Page 75
2.6.1 Adding widgets to a frame……Page 78
2.6.2 Adding a menubar, toolbar, or status bar to a frame……Page 80
2.7 How can I use common dialogs?……Page 82
2.8 What are some common errors with application objects and frames?……Page 84
2.9 Summary……Page 85
Working in an event-driven environment……Page 87
3.1 What terminology do I need to understand events?……Page 88
3.2 What is event-driven programming?……Page 89
3.2.1 Coding event handlers……Page 91
3.2.2 Designing for event-driven programs……Page 92
3.2.3 Event triggers……Page 93
3.3 How do I bind an event to a handler?……Page 94
3.3.1 Working with the wx.EvtHandler methods……Page 96
3.4 How are events processed by wxPython?……Page 99
3.4.1 Understanding the event handling process……Page 100
3.4.2 Using the Skip() method……Page 106
3.6 How can I create my own events?……Page 108
3.6.1 Defining a custom event for a custom widget……Page 109
3.7 Summary……Page 112
Making wxPython easier to handle with PyCrust……Page 114
4.1 How do I interact with a wxPython program?……Page 115
4.2 What are the useful features of PyCrust?……Page 117
4.2.1 Autocompletion……Page 118
4.2.2 Calltips and parameter defaults……Page 119
4.2.3 Syntax highlighting……Page 120
4.2.4 Python help……Page 121
4.2.5 Command recall……Page 122
4.2.6 Cut and paste……Page 123
4.2.7 Standard shell environment……Page 124
4.2.8 Dynamic updating……Page 125
4.3.1 Namespace tab……Page 126
4.3.3 Calltip tab……Page 128
4.3.5 Dispatcher tab……Page 129
4.4 How can I wrap PyCrust around my wxPython application?……Page 130
4.5.1 Working with the GUI programs……Page 135
4.5.2 Working with the support modules……Page 136
4.6 How can I use modules from the Py package in my wxPython programs?……Page 143
4.7 Summary……Page 146
Creating your blueprint……Page 147
5.1 How can refactoring help me improve my code?……Page 148
5.1.1 A refactoring example……Page 149
5.1.2 Starting to refactor……Page 152
5.1.3 More refactoring……Page 153
5.2.1 What is a Model-View-Controller system?……Page 157
5.2.2 A wxPython model: PyGridTableBase……Page 159
5.2.3 A custom model……Page 167
5.3.1 The unittest module……Page 171
5.3.2 A unittest sample……Page 172
5.3.3 Testing user events……Page 174
5.4 Summary……Page 176
Working with the basic building blocks……Page 177
6.1.1 How do I draw on the screen?……Page 179
6.2.1 How do I add and update a status bar?……Page 186
6.2.2 How do I include a submenu or checked menu?……Page 189
6.2.3 How do I include a toolbar?……Page 192
6.3.1 How do I use standard file dialogs?……Page 196
6.3.2 How do I use a standard color picker?……Page 200
6.4.1 How do I lay out widgets?……Page 201
6.4.2 How do I build an about box?……Page 209
6.4.3 How do I build a splash screen?……Page 211
6.5 Summary……Page 212
Part 2 – Essential wxPython……Page 214
Working with the basic controls……Page 216
7.1.1 How do I display static text?……Page 217
7.1.2 How can I get the user to enter text?……Page 220
7.1.3 How do I change the text without user input?……Page 223
7.1.4 How do I create a multi-line or styled text control?……Page 224
7.1.5 How do I create a font?……Page 227
7.1.6 Can I have styled text if my platform doesn’t support rich text?……Page 228
7.1.7 What if my text control doesn’t match my string?……Page 229
7.2 Working with buttons……Page 230
7.2.1 How do I make a button?……Page 231
7.2.2 How do I make a button with a bitmap?……Page 232
7.2.3 How do I create a toggle button?……Page 233
7.2.4 What’s a generic button, and why should I use one?……Page 234
7.3.1 How do I make a slider?……Page 236
7.3.2 How can I get those neat up/down arrow buttons?……Page 239
7.3.3 How can I make a progress bar?……Page 241
7.4.1 How do I create a checkbox?……Page 242
7.4.2 How can I create a group of radio buttons?……Page 243
7.4.3 How can I create a list box?……Page 247
7.4.4 Can I combine a checkbox and a list box?……Page 250
7.4.5 What if I want a pull-down choice?……Page 251
7.4.6 Can I combine text entry and a list?……Page 252
7.5 Summary……Page 253
Putting widgets in frames……Page 255
8.1.1 How do I create a frame?……Page 256
8.1.2 What are some different frame styles?……Page 258
8.1.3 How do I create a frame with extra style information?……Page 261
8.1.4 What happens when I close a frame?……Page 263
8.2.1 What are the methods and properties of wx.Frame?……Page 265
8.2.2 How do I find a subwidget of a frame?……Page 268
8.2.3 How do I create a frame with a scrollbar?……Page 269
8.3.1 How do I create an MDI frame?……Page 273
8.3.2 What’s a mini-frame and why would I use it?……Page 275
8.3.3 How do I make a non-rectangular frame?……Page 276
8.3.4 How can I drag a frame without a title bar?……Page 279
8.4.1 Creating a splitter window……Page 281
8.4.2 A splitter example……Page 282
8.4.3 Changing the appearance of the splitter……Page 284
8.4.4 Manipulating the splitter programmatically……Page 285
8.4.5 Responding to splitter events……Page 286
8.5 Summary……Page 287
Giving users choices with dialogs……Page 289
9.1.1 How do I create a modal dialog?……Page 290
9.1.2 How do I create an alert box?……Page 292
9.1.3 How do I get short text from the user?……Page 295
9.1.4 How can I display a list of choices in a dialog?……Page 297
9.1.5 How can I display progress?……Page 298
9.2.1 How can I use a file picker?……Page 300
9.2.2 How can I use a font picker?……Page 304
9.2.3 How can I use a color picker?……Page 306
9.2.4 Can I allow the user to browse images?……Page 308
9.3 Creating a wizard……Page 309
9.4 Showing startup tips……Page 312
9.5.1 How do I use a validator to ensure correct data?……Page 313
9.5.2 How do I use a validator to transfer data?……Page 317
9.5.3 How do I validate data as it is entered?……Page 319
9.6 Summary……Page 322
Creating and using wxPython menus……Page 324
10.1 Creating Menus……Page 325
10.1.2 How do I create a menu and attach it to the menu bar?……Page 326
10.1.3 How do I add items to a pull-down menu?……Page 328
10.1.4 How do I respond to a menu event?……Page 332
10.2.1 How do I find a specific menu item in a menu?……Page 334
10.2.2 How do I enable or disable a menu item?……Page 337
10.2.3 How do I associate a menu item with a keyboard shortcut?……Page 338
10.2.4 How do I create a toggle menu item with a checkbox or radio button?……Page 342
10.3.1 How do I create a submenu?……Page 344
10.3.2 How do I create a pop-up menu?……Page 346
10.3.3 How can I create fancier menus?……Page 348
10.4.2 Creating logical item groups……Page 350
10.5 Summary……Page 352
Placing widgets with sizers……Page 354
11.1 What’s a sizer?……Page 355
11.2 Basic sizers with the grid sizer……Page 357
11.2.1 What is a grid sizer?……Page 358
11.2.2 How do you add or remove children from a sizer?……Page 360
11.2.3 How do sizers manage the size and alignment of their children?……Page 362
11.2.4 Can I specify a minimum size for my sizer or its children?……Page 365
11.2.5 How do sizers manage the border around each child?……Page 367
11.3.1 What’s a flex grid sizer?……Page 368
11.3.2 What’s a grid bag sizer?……Page 372
11.3.3 What’s a box sizer?……Page 376
11.3.4 What’s a static box sizer?……Page 380
11.4 Can I see a real-world example of sizers in action?……Page 381
11.5 Summary……Page 385
Manipulating basic graphical images……Page 387
12.1.1 How do I load images?……Page 388
12.1.2 What can I do with an image?……Page 392
12.1.3 How can I change cursors?……Page 395
12.2.1 What is a device context, and how can I create one?……Page 398
12.2.2 How do I draw to a device context?……Page 402
12.2.3 How do I draw images to the context?……Page 407
12.2.4 How can I draw text to the context?……Page 410
12.3.1 How do I manage the foreground drawing pen?……Page 412
12.3.2 How do I manage the background drawing brush?……Page 415
12.3.3 How can I manage logical and physical device coordinates?……Page 416
12.3.4 What color names are predefined?……Page 418
12.4 Summary……Page 419
Part 3 – Advanced wxPython……Page 422
Building list controls and managing items……Page 424
13.1.1 What is icon mode?……Page 425
13.1.2 What is small icon mode?……Page 426
13.1.3 What is list mode?……Page 427
13.1.4 What is report mode?……Page 428
13.1.5 How do I create a list control?……Page 429
13.2.1 What is an image list and how do I add images to it?……Page 431
13.2.2 How can I add and delete items from a list?……Page 433
13.3.1 How can I respond to a user selection in a list?……Page 436
13.3.2 How can I respond to a user selection in a column header?……Page 438
13.4.1 How can I edit a label?……Page 442
13.4.2 How can I sort my list?……Page 444
13.4.3 How can I learn more about list controls?……Page 447
13.5 Creating a virtual list control……Page 451
13.6 Summary……Page 454
Coordinating the grid control……Page 456
14.1.1 How do I create a simple grid?……Page 457
14.1.2 How do I create a grid with a grid table?……Page 460
14.2.1 How do I add and delete rows, columns, and cells?……Page 463
14.2.2 How do I manage the row and column headers of a grid?……Page 464
14.2.3 How can I manage the size of grid elements?……Page 467
14.2.4 How can I manage which cells are selected or visible?……Page 471
14.2.5 How do I change the color or font of a grid cell?……Page 473
14.3.1 How do I use a custom cell renderer?……Page 476
14.3.2 How do I edit a cell?……Page 480
14.3.3 How do I use a custom cell editor?……Page 481
14.4.1 How can I capture user mouse selections?……Page 486
14.4.2 How can I capture user keyboard navigation?……Page 488
14.5 Summary……Page 489
Climbing the tree control……Page 491
15.1 Creating tree controls and adding items……Page 492
15.1.2 How do I add more items to the tree?……Page 494
15.1.3 How do I manage items?……Page 495
15.2 What styles control the display of the tree control?……Page 496
15.3 Sorting elements of a tree control……Page 498
15.4 Controlling the image for each item……Page 499
15.5 Navigating the tree programmatically……Page 502
15.6 Managing the tree selection……Page 503
15.7 Controlling which items are visible……Page 504
15.8 Making a tree control user editable……Page 508
15.9 Responding to other user events from a tree control……Page 509
15.10 Using a tree list control……Page 511
15.11 Summary……Page 513
Incorporating HTML into your application……Page 516
16.1.1 How can I display HTML in a wxPython window?……Page 517
16.1.2 How can I display HTML from a file or URL?……Page 519
16.2.1 How can I respond to a user click on an active link?……Page 521
16.2.2 How can I change an HTML window programmatically?……Page 522
16.2.3 How can I display the page title in a frame’s title bar?……Page 524
16.2.4 How can I print an HTML page?……Page 526
16.3.1 How does the HTML parser work?……Page 527
16.3.2 How can I add support for new tags?……Page 529
16.3.3 How can I support other file formats?……Page 532
16.3.4 How can I get a more fully featured HTML Widget?……Page 533
16.4 Summary……Page 534
The wxPython printing framework……Page 535
17.1 How do I print in wxPython?……Page 536
17.1.1 Understanding the printout lifecycle……Page 537
17.1.2 Print framework in action……Page 538
17.1.3 Working with wx.Printout methods……Page 542
17.2.1 Creating a print dialog……Page 543
17.3.1 Creating a page setup dialog……Page 546
17.3.2 Working with page setup properties……Page 547
17.4 How do I print something?……Page 549
17.5 How can I perform a print preview?……Page 550
17.6 Summary……Page 551
Using other wxPython functionality……Page 552
18.1.1 Getting data in the clipboard……Page 553
18.1.2 Manipulating data in the clipboard……Page 554
18.1.4 The clipboard in action……Page 555
18.1.5 Passing other data formats……Page 557
18.2 Being the source of a drag and drop……Page 558
18.2.1 Dragging in action……Page 560
18.3 Being the target of a drag and drop……Page 561
18.3.1 Using your drop target……Page 562
18.3.2 Dropping in action……Page 564
18.4.1 Transferring a custom data object……Page 565
18.4.3 Transferring an object in multiple formats……Page 566
18.5.1 Generating EVT_TIMER events……Page 567
18.6 Creating a multithreaded wxPython application……Page 570
18.6.1 Working with the global function wx.CallAfter()……Page 571
18.6.3 Developing your own solution……Page 574
18.7 Summary……Page 575
C……Page 576
E……Page 577
I……Page 578
O……Page 579
S……Page 580
V……Page 581
W……Page 582
Y……Page 583

Reviews

There are no reviews yet.

Be the first to review “wxPython in Action”
Shopping Cart
Scroll to Top