Book Image

Pyside GUI Application Development- Second Edition - Second Edition

By : Venkateshwaran Loganathan, Gopinath Jaganmohan
Book Image

Pyside GUI Application Development- Second Edition - Second Edition

By: Venkateshwaran Loganathan, Gopinath Jaganmohan

Overview of this book

Elegantly-built GUI applications are always a massive hit among users. PySide is an open source software project that provides Python bindings for the Qt cross-platform UI framework. Combining the power of Qt and Python, PySide provides easy access to the Qt framework for Python developers and also acts as an excellent rapid application development platform. This book will take you through everything you need to know to develop UI applications. You will learn about installing and building PySide in various major operating systems as well as the basics of GUI programming. The book will then move on to discuss event management, signals and slots, and the widgets and dialogs available with PySide. Database interaction and manipulation is also covered. By the end of this book, you will be able to program GUI applications efficiently and master how to develop your own applications and how to run them across platforms.
Table of Contents (13 chapters)


The aim of this book is to introduce you to developing GUI applications in an easy way. Python is easy to learn and use, and its programs are relatively short compared to those written in any other programming languages, such as C++, and Java. It is supported by a large set of dynamic libraries and bindings that make it efficient to develop very complex applications in an efficient manner. This book will introduce you to user interface programming and its components. You will be able to develop real-time applications in a shorter time after reading this book. The second edition.

What this book covers

Chapter 1, Getting Started with PySide, introduces you to GUI programming in general. This chapter takes you through the introduction of PySide and its installation in various major operating systems, followed by a short introduction to exception handling in programming. By the end of this chapter, users will know how to install and use PySide to create GUI applications in Python.

Chapter 2, Entering through Windows, introduces you to all the GUI programming that revolves around Windows. This chapter explains the basic methods of creating windows and adding some functions to them. By the end of this chapter, users will be familiar with how to create windows and modify them accordingly.

Chapter 3, Main Windows and Layout Management, elaborates further on the previous chapter by explaining how to create menus and tool bars for a windowed application. This also explains layout management policies. A simple text editor is given as an example at the end of the chapter. By the end of this chapter, readers have an experience of creating a real-time application in PySide.

Chapter 4, Events and Signals, this chapter goes on to explain the signals, various text and graphic effects, drag and drop, and a few geometrical diagram shapes. By the end of this chapter, readers will learn about managing events and various other text and graphical effects.

Chapter 5, Dialogs and Widgets, details the built-in dialog boxes for applications, introduces how to create customized dialogs, and then takes a look at the various widgets that are available in PySide. By the end of this chapter, you will learn about creating your own customized widgets and dialogs.

Chapter 6, Database Handling, explains how connecting to a database is evident for almost all applications. This chapter is dedicated to explaining how to connect to a database and execute queries on it. It also deals with the presentation of data in table and form views. By the end of this chapter, you will know more about interacting with databases and viewing data from them.

What you need for this book

To execute the examples that are provided in this book, you will require a standard installation of Python v2.6 or later, including Python v3.4, and PySide v1.0.7 or later. A good text editor application, such as Sublime Text, will also help in writing Python programs in an IDE environment.

Who this book is for

Are you a GUI developer or fascinated by GUI programming? Bored with writing several lines of code to create a simple button in GUI? Then this book is for you. This book is written for Python programmers to try their hands at GUI programming. Even if you are new to Python but have some programming experience with any of the object-oriented languages, you will be able to easily pick it up as Python is easy to learn.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text are shown as follows: "The import pyside command should not return any errors".

A block of code is set as follows:

  # Import required modules
import sys, time
from PySide.QtGui import *
from PySide.QtCore import *

Any command-line input or output is written as follows:

brew install pyside
port-install pyXX-pyside

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "On clicking Next in the subsequent windows, and finally clicking Finish".


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.