You are previewing Introduction to Python® Programming and Developing GUI Applications with PyQT.
O'Reilly logo
Introduction to Python® Programming and Developing GUI Applications with PyQT

Book Description

INTRODUCTION TO PYTHON PROGRAMMING AND DEVELOPING GUI APPLICATIONS WITH PYQT 1E teaches Python programming step-by-step through practical examples that readers can see in action right away. It begins with a solid introduction of Python from scratch, covering loops, control structures, sequences, functions, classes, and exception handling. Thereafter, the book explores file handling and GUI application development in PyQT, the powerful cross-platform GUI layout and forms builder that allows programmers to rapidly design and build widgets and dialogs. This is a great book for newbie programmers interested in learning Python

Table of Contents

  1. Copyright
    1. Dedication
  2. Acknowledgments
  3. About the Author
  4. Introduction
    1. How This Book is Organized
    2. Companion Website Downloads
  5. 1. Python and Its Features
    1. Python
      1. Python Implementations
      2. Features of Python
    2. Installing Python
      1. Installing Python on Microsoft Windows
      2. Installing Python on the Mac
      3. Installing Python on UNIX
    3. Interacting with Python
      1. Command Line Mode
      2. IDLE (Integrated DeveLopment Environment)
    4. Writing Your First Python Program
      1. Running Python Programs from the Command Prompt
    5. Data Types in Python
    6. Basic Elements in a Program
      1. Literals
      2. Variables
      3. Keywords
    7. Comments
    8. Continuation Lines
    9. Printing
    10. Summary
  6. 2. Getting Wet in Python
    1. Performing Arithmetic Operations
      1. Division Operator
      2. Exponentiation
      3. Multiple Assignment Statement
      4. Using Escape Sequences
        1. Finding a Data Type
        2. Displaying Octal and Hexa Values
        3. Getting Data
        4. Coercion
        5. Converting Explicitly into integer Type
    2. Bitwise Operations
    3. Complex Numbers
    4. Making Decisions
      1. if...else statement
      2. if-elif-else statement
    5. Logical Operators
    6. Chaining Comparison Operators
    7. Loops
      1. The while Loop
        1. Indentation
        2. Breaking and Continuing a Loop
          1. The break Statement
          2. The continue Statement
          3. The pass Statement
          4. The range () Function
      2. The for Loop
        1. Membership Operators
        2. The choice () Function
    8. Summary
  7. 3. Sequences
    1. Sequences
    2. Strings
      1. How Characters Are Stored in a String
        1. Differences Between Functions and Methods
          1. Finding the Length of a String
      2. Arrays
        1. One-Dimensional Arrays
        2. Two-Dimensional Arrays
    3. Lists
      1. Finding the Length of the List
      2. List Slicing
    4. Tuples
      1. Dictionary
    5. Sets
      1. Union (|)
      2. Intersection (&)
      3. Difference (-)
    6. Summary
  8. 4. Functions and Modules
    1. Functions
      1. The def Statement
      2. The return Statement
      3. Default Value Parameters
      4. Keyword Arguments
      5. Local and Global Variables
        1. Global Variables
        2. Local Variables
      6. Lambda Functions
      7. Applying Functions to Sequences
    2. Function Attributes
      1. Documentation String
    3. Recursion
    4. Iterators
      1. Generators
      2. Generator Expression
    5. Modules
      1. The math Module
        1. The dir() Function
        2. Command-Line Arguments
    6. Summary
  9. 5. Classes
    1. The Class Statement
      1. Attributes of Class Objects
      2. Built-In Class Attributes
      3. Defining Functions in a Class
        1. Accessing Class Variables in Instance Methods
      4. Instances
        1. The __init__() Method
          1. Passing Arguments to the __init__ Method
          2. Defining Default Value Parameters in the __init__ Method
          3. String Representation of an Instance
    2. Class Methods
    3. Static Methods
      1. Assigning One Instance to Another
    4. Garbage Collection
    5. Inheritance
      1. Types of Inheritance
        1. Single Inheritance
        2. Access Control Specifiers
          1. Accessing public Members
          2. Accessing private Members
          3. Method Overriding
          4. Accessing Methods of a Base Class from a Derived Class
    6. Multilevel Inheritance
      1. Two Classes Inheriting from the Same Base Class
      2. Multiple Inheritance
        1. Two Base Classes Having a Method with the Same Name and Signature
    7. Operator Overloading
      1. Overloading the Comparison Operator (==)
        1. Polymorphism
        2. Properties
    8. Descriptors
      1. The __setattr__ Method
      2. The __getattr__ Method
      3. The __delattr__ Method
    9. Summary
  10. 6. File Handling
    1. Exception Handling
      1. Using a try/except Block
      2. Using a try/finally Block
    2. Raising an Exception
      1. The assert Statement
    3. Summary
  11. 7. PyQt
    1. Qt Toolkit
    2. PyQt
    3. Installing PyQt
    4. Window and Dialogs
      1. Ways of Creating GUI Applications
    5. Creating a GUI Application with Code
    6. Using Qt Designer
      1. Widget Box
        1. Layouts
        2. Spacers
        3. Buttons
        4. Item Views (Model-Based)
        5. Item Widgets (Item-Based)
        6. Containers
        7. Input Widgets
        8. Display Widgets
        9. Phonon
      2. Toolbar
    7. Understanding Fundamental Widgets
      1. Displaying Text
      2. Entering Single-Line Data
      3. Displaying Buttons
    8. Event Handling in PyQt
    9. First Application in Qt Designer
      1. Connecting to Predefined Slots
    10. Using Custom Slots
    11. Converting Data Types
    12. Defining Buddies
      1. Setting Tab Order
    13. Summary
  12. 8. Basic Widgets
    1. Using Radio Buttons
    2. Using Checkboxes
      1. Initiating Action Without Using a Push Button
    3. Entering Integer and Float Values Using a Spin Box
    4. ScrollBars and Sliders
      1. ScrollBars
      2. Sliders
    5. Working with a List Widget
      1. Adding Items to a List Widget
      2. Performing Operations on a List Widget
        1. Using List Items
        2. Displaying an Input Dialog Box
    6. Summary
  13. 9. Advanced Widgets
    1. Displaying System Clock Time in LCD Format
      1. Displaying LCD Digits
        1. Using Timers
        2. Fetching and Measuring System Clock Time
    2. Working with Calendar and Displaying Dates in Different Formats
      1. Displaying Calendar
      2. QDate Class
      3. Using the Date Edit Widget
    3. Using Combo Box
    4. Displaying a Table
      1. Displaying Items in the Table
    5. Displaying Web Pages
    6. Displaying Graphics
    7. Summary
  14. 10. Menus and Toolbars
    1. Understanding Menus
      1. Action Editor
      2. Creating a Menu
    2. Creating a Toolbar
      1. Creating a Resource File
    3. Dock Widget
    4. Tab Widget
      1. Working with the Style Sheet Editor
    5. Converting a Tab Widget
      1. Converting a Tab Widget into a Tool Box
      2. Converting Tab Widget into Stacked Widget
    6. Summary
  15. 11. Multiple Documents and Layouts
    1. Multiple-Document Interface
    2. Layouts
      1. Horizontal Layout
      2. Using a Group Box
      3. Vertical Layout
      4. Using the Grid Layout
    3. Summary
  16. 12. Database Handling
    1. Why MySQL?
      1. MySQLdb
      2. Installation of MySQLdb
    2. Creating a Database
      1. Creating a Database Table
        1. use database_name
        2. show tables
        3. describe table_name
    3. Database Maintenance Through Console-Based Programs
      1. Inserting Rows in a Database Table
        1. commit()
        2. rollback()
        3. Fetching Rows from the Table
        4. Searching in a Database Table
        5. Updating Information in a Database Table
        6. Deleting Information from a Database Table
    4. Database Maintenance Through GUI Programs
      1. QSqlDatabase Class
      2. Displaying Rows
        1. QSqlTableModel Class
        2. Navigating Through Rows of the Database Table
        3. Maintaining the Database Table
    5. Summary