26,39 €
Develop more dynamic and robust GUI applications using PySide, an open source cross-platform UI framework
This book is written for Python programmers who want to learn about GUI programming. It is also suitable for those who are new to Python but are familiar with object-oriented programming.
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.
This is an accessible and practical guide to developing GUIs for Python applications.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 155
Veröffentlichungsjahr: 2016
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2013
Second Edition: January 2016
Production reference: 1200116
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-245-4
www.packtpub.com
Authors
Gopinath Jaganmohan
Venkateshwaran Loganathan
Reviewer
Sivan Greenberg
Commissioning Editor
Dipika Gaonkar
Acquisition Editors
Greg Wild
Meeta Rajani
Content Development Editor
Mamata Walkar
Technical Editor
Siddhesh Patil
Copy Editor
Priyanka Ravi
Project Coordinator
Shipra Chauhan
Proofreader
Safis Editing
Indexer
Monica Ajmera Mehta
Graphics
Disha Haria
Production Coordinator
Conidon Miranda
Cover Work
Conidon Miranda
Gopinath Jaganmohan is an Internet of Things evangelist and open source distributed-computing architect. He has 14 years of experience in various industries and has architected and lead implementation in Internet of Things platforms and solutions for enterprise in Telematics, Healthcare, and Wearables. He has worked on various technologies starting from C, Python, Lua, to Node.js, and implemented Big Data technologies like Hbase, Couchbase and ZooKeeper for various clients. He is passionate about device programming and device integration. He is lately working on deep learning technologies like Keras, scikit, Torch7 and Pandas in machine learning for device data.
Venkateshwaran Loganathan is an eminent software developer who has been involved in the design, development, and testing of software products for more than five years now. He was introduced to computer programming at an early age of 11 with FoxPro, and he then started to learn and master various computer languages, such as C, C++, Perl, Python, Node.js, and Unix shell scripting. Fascinated by open source development, he has involved himself in contributing to various open source technologies.
He is now working for Cognizant Technology Solutions as a technology specialist where he has involved himself in research and development for the Internet of Things domain. He is now actively involved in using RFID devices, Drones, and Google Glass to evolve Future of Technology concepts. Before joining with Cognizant, he worked with few of the IT majors, such as Infosys, Virtusa, and NuVeda. Starting his career as a network developer, he gained expertise in various domains, such as Networking, E-Learning, and HealthCare. He has won various awards and accolades to his merit in the companies he has worked for.
Venkateshwaran holds a bachelor's degree in Computer Science and Engineering from Anna University and an M.S in software systems from BITS, Pilani. Apart from programming, he is actively involved in handling various technical and soft skills classes for budding engineers and college students. His hobbies include singing and trekking. He likes to get involved with social servicing and move with people a lot. You can write to him at <[email protected]>.
I am indebted to many. First of all, I would like to thank my mother, Anbuselvi, and grandmother, Saraswathi, for their endless effort and perseverance in bringing me up to this level. I am thankful to the entire team at Packt for accepting my proposal in bringing out a book of this kind. I would like to especially mention Meeta, Neil, and Amigya for their valuable guidance throughout the writing of the manuscript.
I am very grateful to my technical reviewers, Oscar Campos, and Jibo He, for reviewing the manuscript and providing me with constructive feedback that helped me shape the content. I would also like to extend my sincere gratitude to my professors, Senthil Kumar, and Radhika, for guiding me and encouraging me in all my spheres of life. I would not be very kind if I missed thanking my sister, Kamala, and my aunt, Kalavathi, for all the hope and love they have towards me.
I would also like to thank all my friends and brothers as their list is too big to mention here. They all have been my well-wishers and helped me in my tough times. I have missed many people here, but my thanks are always due to them who directly or indirectly influenced my life.
Above all, thanks to The Almighty for the showers of blessings on me.
Sivan Greenberg has over 15 years of multidisciplinary information technology expertise and a sharp eye for quality. He became an open source contributor for the Debian project back in 2002, joining Ubuntu two years later. Sivan's contribution can be found, literally, all over the world of open source.
Sivan is a true jack of all trades with massive engineering and leadership experience. He uses Python for all of his development needs ever since it was pitched to him by The SABDFL and the Ubuntu community. Currently, he runs Vitakka.co, a rapid development consultancy firm together with a team of veterans of long open source fame. They enable start-ups to realize and implement their MVPs so that they can bootstrap quickly and easily by acquiring customers and getting noticed by VCs. The team's mastery of everything cloud, software, engineering, operations, and product management make this an extremely high quality game-changing process.
I would like to thank my Mom, Helena, and my family—Moshik, Shir, and Eric. You're the fuel that makes me tick. Mom, you planted and nurtured the seeds of knowledge in me.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
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.
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.
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.
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:
Any command-line input or output is written as follows:
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.
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 <[email protected]>, 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 www.packtpub.com/authors.
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.
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support 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 http://www.packtpub.com/submit-errata, 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 https://www.packtpub.com/books/content/support 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 <[email protected]> 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 <[email protected]>, and we will do our best to address the problem.
Python is a general-purpose, interpreted, object-oriented, and high-level programming language with dynamic semantics. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. It is one of the most preferred programming languages by software developers due to its interpreted nature and its elegant syntax.
The success of Python lies in its simple and easy-to-learn syntax and the support of a wide variety of modules and packages that encourage program modularity and code reuse. Being an interpreted language, there is no compilation step, which makes the edit-test-debug cycle incredibly fast, paving the way to Rapid Application Development, the need of the hour. The support of object-oriented features and high-level data structures, such as generators and list comprehensions, makes Python a superior language for coding small scripting programs to more advanced game programming.
