Rapid GUI Programming with Python and Qt

The Definitive Guide to PyQt Programming

Mark Summerfield

Publisher: Prentice Hall, 2008, 626 pages

ISBN: 0-13-235418-7

Keywords: Python

Last modified: Aug. 15, 2009, 2:20 a.m.

The Insider's Best-Practice Guide to Rapid PyQt 4 GUI Development

Whether you're building GUI prototypes or full-fledged cross-platform GUI applications with native look-and-feel, PyQt 4 is your fastest, easiest, most powerful solution. Qt expert Mark Summerfield has written the definitive best-practice guide to PyQt 4 development.

With Rapid GUI Programming with Python and Qt you'll learn how to build efficient GUI applications that run on all major operating systems, including Windows, Mac OS X, Linux, and many versions of Unix, using the same source code for all of them. Summerfield systematically introduces every core GUI development technique: from dialogs and windows to data handling; from events to printing; and more. Through the book's realistic examples you'll discover a completely new PyQt 4-based programming approach, as well as coverage of many new topics, from PyQt 4's rich text engine to advanced model/view and graphics/view programming. Every key concept is illuminated with realistic, downloadable examples—all tested on Windows, Mac OS X, and Linux with Python 2.5, Qt 4.2, and PyQt 4.2, and on Windows and Linux with Qt 4.3 and PyQt 4.3.

Coverge includes

  • Python basics for every PyQt developer: data types, data structures, control structures, classes, modules, and more
  • Core PyQt GUI programming techniques: dialogs, main windows, and custom file formats
  • Using Qt Designer to design user interfaces, and to implement and test dialogs, events, the Clipboard, and drag-and-drop
  • Building custom widgets: Widget Style Sheets, composite widgets, subclassing, and more
  • Making the most of Qt 4.2's new graphics/view architecture
  • Connecting to databases, executing SQL queries, and using form and table views
  • Advanced model/view programming: custom views, generic delegates, and more
  • Implementing online help, internationalizing applications, and using PyQt's networking and multithreading facilities
  • Foreword
  • Introduction
  • Part I: Python Programming
    • Chapter 1. Data Types and Data Structures
      • Executing Python Code
      • Variables and Objects
      • Numbers and Strings
        • Integers and Long Integers
        • Floats and Decimals
        • Bytestrings, Unicode Strings, and QStrings
      • Collections
        • Tuples
        • Lists
        • Dictionaries
        • Sets
      • Built-in Functions
      • Summary
      • Exercises
    • Chapter 2. Control Structures
      • Conditional Branching
      • Looping
        • List Comprehensions and Generators
      • Functions
        • Generator Functions
        • Using Keyword Arguments
        • Lambda Functions
        • Dynamic Function Creation
        • Partial Function Application
      • Exception Handling
      • Summary
      • Exercises
    • Chapter 3. Classes and Modules
      • Creating Instances
      • Methods and Special Methods
        • Static Data, and Static Methods and Decorators
        • Example: The Length Class
        • Collection Classes
        • Example: The OrderedDict Class
      • Inheritance and Polymorphism
      • Modules and Multifile Applications
        • Using the doctest Module
      • Summary
      • Exercises
  • Part II: Basic GUI Programming
    • Chapter 4. Introduction to GUI Programming
      • A Pop-Up Alert in 25 Lines
      • An Expression Evaluator in 30 Lines
      • A Currency Converter in 70 Lines
      • Signals and Slots
      • Summary
      • Exercise
    • Chapter 5. Dialogs
      • Dumb Dialogs
      • Standard Dialogs
        • Modal OK/Cancel-Style Dialogs
      • Smart Dialogs
        • Modeless Apply/Close-Style Dialogs
        • Modeless "Live" Dialogs
      • Summary
      • Exercise
    • Chapter 6. Main Windows
      • Creating a Main Window
        • Actions and Key Sequences
        • Resource Files
        • Creating and Using Actions
        • Restoring and Saving the Main Window's State
      • Handling User Actions
        • Handling File Actions
        • Handling Edit Actions
        • Handling Help Actions
      • Summary
      • Exercise
    • Chapter 7. Using Qt Designer
      • Designing User Interfaces
      • Implementing Dialogs
      • Testing Dialogs
      • Summary
      • Exercise
    • Chapter 8. Data Handling and Custom File Formats
      • Main Window Responsibilities
      • Data Container Responsibilities
      • Saving and Loading Binary Files
        • Writing and Reading Using QDataStream
        • Writing and Reading Using the pickle Module
      • Saving and Loading Text Files
        • Writing and Reading Using QTextStream
        • Writing and Reading Using the codecs Module
      • Saving and Loading XML Files
        • Reading and Parsing XML with PyQt's DOM Classes
        • Reading and Parsing XML with PyQt's SAX Classes
      • Summary
      • Exercise
  • Part III: Intermediate GUI Programming
    • Chapter 9. Layouts and Multiple Documents
      • Layout Policies
      • Tab Widgets and Stacked Widgets
        • Extension Dialogs
      • Splitters
      • Single Document Interface (SDI)
      • Multiple Document Interface (MDI)
      • Summary
      • Exercise
    • Chapter 10. Events, the Clipboard, and Drag and Drop
      • The Event-Handling Mechanism
      • Reimplementing Event Handlers
      • Using the Clipboard
      • Drag and Drop
        • Handling Custom Data
      • Summary
      • Exercise
    • Chapter 11. Custom Widgets
      • Using Widget Style Sheets
      • Creating Composite Widgets
      • Subclassing Built-in Widgets
      • Subclassing QWidget
        • Example: A Fraction Slider
        • Example: A Flow-Mixing Widget
      • Summary
      • Exercise
    • Chapter 12. Item-Based Graphics
      • Custom and Interactive Graphics Items
      • Animation and Complex Shapes
      • Summary
      • Exercise
    • Chapter 13. Rich Text and Printing
      • Rich Text Editing
        • Using QSyntaxHighlighter
        • A Rich Text Line Edit
      • Printing Documents
        • Printing Images
        • Printing Documents Using HTML and QTextDocument
        • Printing Documents Using QTextCursor and QTextDocument
        • Printing Documents Using QPainter
      • Summary
      • Exercise
    • Chapter 14. Model/View Programming
      • Using the Convenience Item Widgets
      • Creating Custom Models
        • Implementing the View Logic
        • Implementing the Custom Model
      • Creating Custom Delegates
      • Summary
      • Exercise
    • Chapter 15. Databases
      • Connecting to the Database
      • Executing SQL Queries
      • Using Database Form Views
      • Using Database Table Views
      • Summary
      • Exercise
  • Part IV: Advanced GUI Programming
      • Chapter 16. Advanced Model/View Programming
        • Custom Views
        • Generic Delegates
        • Representing Tabular Data in Trees
        • Summary
        • Exercise
      • Chapter 17. Online Help and Internationalization
        • Online Help
        • Internationalization
        • Summary
        • Exercise
      • Chapter 18. Networking
        • Creating a TCP Client
        • Creating a TCP Server
        • Summary
        • Exercise
      • Chapter 19. Multithreading
        • Creating a Threaded Server
        • Creating and Managing Secondary Threads
        • Implementing a Secondary Thread
        • Summary
        • Exercise
        • This Is Not Quite the End
      • Appendix A. Installing
        • Installing on Windows
        • Installing on Mac OS X
        • Installing on Linux and Unix
    • Appendix B. Selected PyQt Widgets
    • Appendix C. Selected PyQt Class Hierarchies

Reviews

Rapid GUI Programming with Python and Qt

Reviewed by Roland Buresund

Very Good ******** (8 out of 10)

Last modified: Aug. 15, 2009, 2:23 a.m.

OK, a disclaimer: I like Python, and I've used KDE/Qt before (with success, in C++), but I dislike GUI-programming with a vengance! With that out of my system, I must admit that this book made GUI programming a pleasure, in combination with Python (which I've used with TK and wxWindows before).

Anyway, beware that even though the book is pretty big, it doesn't in any way contain the detailed descriptions of the interfaces, as you must read these from the "official" Qt -documentation, which is geared to C++. It is a very good tutorial and overview, not the last word on the documentation of PyQt as the sub-title may lead you to believe.

Anyway, ity achieves it aims, and I give it my strong recommendation.

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required