Qt5 Python GUI Programming Cookbook

Book description

Over 60 recipes to help you design interactive, smart, and cross-platform GUI applications

Key Features

  • Get succinct QT solutions to pressing GUI programming problems in Python
  • Learn how to effectively implement reactive programming
  • Build customized applications that are robust and reliable

Book Description

PyQt is one of the best cross-platform interface toolkits currently available; it's stable, mature, and completely native. If you want control over all aspects of UI elements, PyQt is what you need. This book will guide you through every concept necessary to create fully functional GUI applications using PyQt, with only a few lines of code.

As you expand your GUI using more widgets, you will cover networks, databases, and graphical libraries that greatly enhance its functionality. Next, the book guides you in using Qt Designer to design user interfaces and implementing and testing dialogs, events, the clipboard, and drag and drop functionality to customize your GUI. You will learn a variety of topics, such as look and feel customization, GUI animation, graphics rendering, implementing Google Maps, and more. Lastly, the book takes you through how Qt5 can help you to create cross-platform apps that are compatible with Android and iOS. You will be able to develop functional and appealing software using PyQt through interesting and fun recipes that will expand your knowledge of GUIs

What you will learn

  • Use basic Qt components, such as a radio button, combo box, and sliders
  • Use QSpinBox and sliders to handle different signals generated on mouse clicks
  • Work with different Qt layouts to meet user interface requirements
  • Create custom widgets and set up customizations in your GUI
  • Perform asynchronous I/O operations and thread handling in the Python GUI
  • Employ network concepts, internet browsing, and Google Maps in UI
  • Use graphics rendering and implement animation in your GUI
  • Make your GUI application compatible with Android and iOS devices

Who this book is for

If you're an intermediate Python programmer wishing to enhance your coding skills by writing powerful GUIs in Python using PyQT, this is the book for you.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Qt5 Python GUI Programming Cookbook
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    5. Get in touch
      1. Reviews
  7. Creating a User Interface with Qt Components
    1. Introduction
      1. PyQt
      2. Ways of creating GUI applications
    2. Displaying a welcome message
      1. Understanding the Label widget
        1. Methods
      2. Understanding the Line Edit widget
        1. Methods
      3. Understanding the Push Button widget
      4. How to do it...
      5. How it works...
    3. Using the Radio Button widget
      1. Understanding Radio Button
        1. Methods 
        2. Signal description
      2. How to do it...
      3. How it works...
    4. Grouping radio buttons
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Displaying options in the form of checkboxes
      1. Getting ready
        1. Method application
        2. Signal description
      2. How to do it...
      3. How it works...
    6. Displaying two groups of checkboxes
      1. Getting ready
      2. How to do it...
      3. How it works...
  8. Event Handling - Signals and Slots
    1. Introduction
    2. Using Signal/Slot Editor
      1. How to do it...
    3. Copying and pasting text from one Line Edit widget to another
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Converting data types and making a small calculator
      1. How to do it...
      2. How it works...
    5. Using the Spin Box widget
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Using scrollbars and sliders
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Using List Widget
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Selecting multiple list items from one List Widget and displaying them in another
      1. How to do it...
      2. How it works...
    9. Adding items into List Widget
      1. How to do it...
      2. How it works...
    10. Performing operations in List Widget
      1. Getting ready
        1. Methods provided by the QListWidgetItem class
      2. How to do it....
      3. How it works...
    11. Using the Combo Box widget
      1. How to do it…
      2. How it works...
    12. Using the Font Combo Box widget
      1. Getting ready
      2. How to do it…
      3. How it works...
    13. Using the Progress Bar widget
      1. Getting ready
      2. How to do it…
      3. How it works...
  9. Working with Date and Time
    1. Displaying LCD digits
      1. Using Timers
      2. Using the QTime class
    2. Displaying system clock time in LCD-like digits
      1. How to do it...
      2. How it works...
    3. Displaying the date selected by the user from Calendar Widget
      1. Getting ready
        1. Displaying a calendar
        2. Using the QDate class
        3. Using the Date Edit widget
      2. How to do it...
      3. How it works...
    4. Creating a hotel reservation form 
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Displaying tabular data using Table Widget
      1. Getting ready
        1. Table Widget
        2. The QTableWidgetItem class
      2. How to do it...
      3. How it works...
  10. Understanding OOP Concepts
    1. Object-oriented programming
      1. Creating a class
      2. Using the built-in class attributes
        1. Accessing class variables in instance methods
          1. Instances
    2. Using classes in GUI
      1. How to do it...
      2. How it works...
        1. Making the application more elaborate
        2. Inheritance
          1. Types of inheritance
    3. Using single inheritance
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Using multilevel inheritance
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Using multiple inheritance
      1. Getting ready
      2. How to do it...
      3. How it works...
  11. Understanding Dialogs
    1. Introduction
    2. The input dialog box
    3. Using the input dialog 
      1. How to do it...
      2. How it works...
    4. Using the color dialog
      1. How to do it...
      2. How it works...
    5. Using the font dialog
      1. How to do it...
      2. How it works...
    6. Using the file dialog
      1. Getting ready
      2. How to do it...
      3. How it works...
  12. Understanding Layouts
    1. Understanding layouts
      1. Spacers
    2. Using Horizontal Layout
      1. How to do it...
      2. How it works...
    3. Using Vertical Layout
      1. How to do it...
      2. How it works...
    4. Using Grid Layout
      1. How to do it...
      2. How it works...
    5. Using Form Layout
      1. Getting ready
      2. How to do it...
      3. How it works...
  13. Networking and Managing Large Documents
    1. Introduction
    2. Creating a small browser
      1. How to do it...
      2. How it works...
    3. Creating a server-side application
      1. How to do it...
      2. How it works...
    4. Establishing client-server communication
      1. How to do it...
      2. How it works...
    5. Creating a dockable and floatable sign-in form
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Multiple Document Interface 
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Displaying information in sections using Tab Widget
      1. How to do it...
      2. How it works...
    8. Creating a custom menu bar
      1. How to do it…
      2. How it works...
  14. Doing Asynchronous Programming in Python
    1. Introduction
      1. Multithreading
      2. Asynchronous programming
    2. Updating progress bar using thread
      1. How to do it...
      2. How it works...
    3. Updating two progress bars using two threads
      1. How to do it...
      2. How it works...
    4. Updating progress bars using threads bound with a locking mechanism
      1. How to do it...
      2. How it works...
    5. Updating progress bars simultaneously using asynchronous operations
      1. How to do it...
      2. How it works...
    6. Managing resources using context manager
      1. Context manager
      2. How to do it…
      3. How it works...
  15. Database Handling
    1. Introduction
      1. Creating the cursor object
    2. Creating a database
      1. How to do it…
      2. How it works…
    3. Creating a database table
      1. How to do it…
      2. How it works…
    4. Inserting rows in the specified database table
      1. How to do it…
      2. How it works…
    5. Displaying rows in the specified database table
      1. How to do it…
      2. How it works…
    6. Navigating through the rows of the specified database table
      1. How to do it…
      2. How it works…
    7. Searching a database table for specific information
      1. How to do it…
      2. How it works…
    8. Creating a signin form – applying an authentication procedure
      1. How to do it…
      2. How it works…
    9. Updating a database table – changing a user's password 
      1. How to do it…
      2. How it works…
    10. Deleting a row from a database table
      1. How to do it…
      2. How it works…
  16. Using Graphics
    1. Introduction
    2. Displaying mouse coordinates
      1. How to do it...
      2. How it works...
    3. Displaying coordinates where the mouse button is clicked and released
      1. How to do it...
      2. How it works...
    4. Displaying a point where the mouse button is clicked
      1. How to do it...
      2. How it works...
    5. Drawing a line between two mouse clicks
      1. How to do it...
      2. How it works...
    6. Drawing lines of different types
      1. How to do it...
      2. How it works...
    7. Drawing a circle of a desired size
      1. How to do it...
      2. How it works...
    8. Drawing a rectangle between two mouse clicks
      1. How to do it...
      2. How it works...
    9. Drawing text in a desired font and size
      1. How to do it...
      2. How it works...
    10. Creating a toolbar that shows different graphics tools
      1. How to do it…
      2. How it works...
    11. Plotting a line using Matplotlib
      1. Getting ready
      2. How to do it...
      3. How it works...
    12. Plotting a bar using Matplotlib
      1. Getting ready
      2. How to do it...
      3. How it works...
  17. Implementing Animation
    1. Introduction
      1. Implementing animation
    2. Displaying a 2D graphical image
      1. How to do it...
      2. How it works...
    3. Making a ball move down on the click of a button
      1. How to do it...
      2. How it works...
    4. Making a bouncing ball
      1. How to do it...
      2. How it works...
    5. Making a ball animate as per the specified curve
      1. How to do it...
      2. How it works...
  18. Using Google Maps
    1. Introduction
    2. Finding out details of a location or a landmark
      1. How to do it…
      2. How it works…
    3. Getting complete information from latitude and longitude values
      1. How to do it…
      2. How it works…
    4. Finding out the distance between two locations
      1. How to do it…
      2. How it works…
    5. Displaying location on Google Maps 
      1. How to do it…
      2. How it works…
  19. Running Python Scripts on Android and iOS
    1. Introduction
    2. Copying scripts from PC to Android devices
      1. How to do it
    3. Prompting for a username and displaying a welcome message
      1. How to do it...
      2. How it works...
    4. Understanding different buttons in a dialog box
      1. How to do it...
      2. How it works...
    5. Performing single selection from a list
      1. How to do it...
      2. How it works...
    6. Performing multiple selections from a list
      1. How to do it...
      2. How it works...
    7. Displaying a Date Picker dialog
      1. How to do it...
      2. How it works...
    8. Capturing images using a camera
      1. How to do it...
      2. How it works...
    9. Making an Android device speak a text input
      1. How to do it...
      2. How it works...
    10. Creating a cross-platform Python script using Kivy
      1. Getting started
      2. How to do it...
    11. Packaging a Python Script into the Android APK using Buildozer
      1. Getting ready
      2. How to do it...
      3. How it works
    12. Packaging Python script for iOS
      1. How to do it...
      2. How it works...
  20. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Qt5 Python GUI Programming Cookbook
  • Author(s): B.M. Harwani
  • Release date: July 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788831000