Previous Next

Python GUI with PyQt - Learn to build modern and stunning GUIs in Python with PyQt5 and Qt Designer (Saurabh Chandrakar etc.) (z-library.sk, 1lib.sk, z-lib.sk)

Author: Saurabh Chandrakar, Nilesh Bhaskarrao Bahadure

Python

Python GUI with PyQt is an invaluable guide for both novice and experienced programmers who want to master the art of creating visually appealing and interactive graphical user interfaces (GUIs) for Python applications using the PyQt5 library and the Qt Designer visual layout tool. It covers all the essential concepts of PyQt5 GUI programming in a comprehensive and beginner-friendly manner. The book starts with the basics of GUI programming, such as creating windows, using layout managers, and managing signals and events. It then covers more advanced topics, such as creating dialog and message boxes, using container, input, item views, and display widgets. Then it teaches you to connect signals to slots, the cornerstone of event-driven programming, and discover how to utilize Qt Designer, a visual GUI design tool, to streamline the development process. As you progress, delve into the realm of containers, learning to organize and manage widgets with finesse. Explore the vast array of input widgets, enabling users to seamlessly provide data. You finally conclude your journey by mastering the art of display widgets, empowering you to present information with clarity and elegance. The book is also highly interactive, with practical examples and exercises at the end of each chapter. These help you solidify your understanding of the concepts and gain practical experience in PyQt5 GUI programming. Overall, this is an excellent book for anyone who wants to learn how to create GUI applications in Python using PyQt5 and Qt Designer.

📄 File Format: PDF
💾 File Size: 8.8 MB
4
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
(This page has no text content)
📄 Page 2
(This page has no text content)
📄 Page 3
Python GUI with PyQt Learn to build modern and stunning GUIs in Python with PyQt5 and Qt Designer Saurabh Chandrakar Dr. Nilesh Bhaskarrao Bahadure
📄 Page 4
www.bpbonline.com
📄 Page 5
Copyright © 2024 BPB Online 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 author, nor BPB Online or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. BPB Online has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, BPB Online cannot guarantee the accuracy of this information. First published: 2024 Published by BPB Online WeWork 119 Marylebone Road London NW1 5PU UK | UAE | INDIA | SINGAPORE ISBN 978-93-55515-575 www.bpbonline.com
📄 Page 6
Dedicated to My Parents Dr. Surendra Kumar Chandrakar and Smt. Bhuneshwari Chandrakar brother Shri Pranav Chandrakar, Sister in law Smt. Silky Chandrakar to my wife Smt. Priyanka Chandrakar and to my lovely son Master Yathartha Chandrakar - Saurabh Chandrakar My Parents Smt. Kamal B. Bahadure and Late Bhaskarrao M. Bahadure to my in-laws Smt. Saroj R. Lokhande and Shri Ravikant A. Lokhande and to my wife Shilpa N. Bahadure and to beautiful daughters
📄 Page 7
Nishita and Mrunmayee and to all my beloved students - Dr. Nilesh Bhaskarrao Bahadure
📄 Page 8
About the Authors Saurabh Chandrakar is a Research & Development Engineer (Dy. Manager) at Bharat Heavy Electricals Limited (BHEL) Hyderabad. He is the winner of the best executive award on Operations Division by BHEL Hyderabad. Recently, he has been awarded the prestigious BHEL Excellence Award under Anusandhan category for Redundant Composite Monitoring System of Power Transformers project. He has 23 copyrights and 3 patent granted. Additionally, he has 4 patents filed. Moreover, he has published 5 books in reputed publications such as BPB New Delhi (Programming Techniques using Python, Python for everyone. Building Modern GUIs with tkinter and python), Scitech Publications Chennai (Programming Techniques using matlab) and IK International publishers (Microcontrollers and Embedded System Design). Additionally, he has also launched one video course on BPB titled “First Time Play with Basic, Advanced Python concepts and complete guide for different python certification exams all in one umbrella.” Dr. Nilesh Bhaskarrao Bahadure received the Bachelor of Engineering degree in Electronics Engineering in 2000, the Master of Engineering degree in Digital Electronics in 2005, and the Ph.D. degree in Electronics in 2017 from KIIT Deemed to be University, Bhubaneswar, India. He is currently an
📄 Page 9
Associate Professor in the Department of Computer Science and Engineering at Symbiosis Institute of Technology (SIT), Nagpur, Symbiosis International (Deemed University) (SIU), Pune, Maharashtra, India. He has more than 20 years of experience. Dr. Bahadure is a life member of IE(I), IETE, ISTE, ISCA, SESI, ISRS, and IAENG professional organizations. He has published more than 40 articles in reputed international journals and conferences, and has five books to his credit. He is the reviewer of many indexed journals such as IEEE Access, IET, Springer, Elsevier, Wiley and so on. His research interests are in the areas of Sensor Technology, the Internet of Things, and Biomedical Image Processing.
📄 Page 10
About the Reviewer Prasenjeet Damodar Patil is currently working as an Associate Professor at the School of Computing, M.I.T A.D.T University, Pune. He has completed his B.E. in E&TC Engg. and M. Tech. in Electronics from Walchand College of Engineering Sangli, India. He did his Ph.D. in E&TC Engineering in 2018. Prasanjeet has 14+ years of teaching experience and has published more than 16 papers in reputed Journals. His research interest includes Computational Electromagnetics applications in Integrated Optics, IoT, and digital Image Processing.
📄 Page 11
Acknowledgements First and foremost, I would like to thank you all for selecting this book. It has been written with the beginner reader in mind. First of all, I take this opportunity to greet and thank my mentor "Prof. Nilesh Bahadure Sir" for motivating me and always communicating his expertise fully on topics related to Python. I am very thankful for being his protégé. I appreciate his belief in me for always standing behind me and pushing me to achieve more. The phrase "Journey of a Thousand Miles Begins with a Single Step" is something he always reminds me of. My parents, Dr. Surendra Kumar Chandrakar and Smt. Bhuneshwari Chandrakar, my brother, Shri Pranav Chandrakar, my sister-in-law Silky Chandrakar, my beloved wife, Mrs. Priyanka Chandrakar, my adorable son Yathartha Chandrakar, and all of my friends have inspired me and given me confidence over the years. Last but not the least, I would like to express my sincere gratitude to the staff at BPB Publications for their contributions and insights that made parts of this book possible. — Saurabh Chandrakar It was my privilege to thank Dr. S. B. Mujumdar, Chancellor of the Symbiosis International University, Pune, and Shri. Vijay Kumar Gupta, Chairman of Beekay Industries Bhilai and BIT Trust, for his encouragement and support. I thank my mentors, Dr. Arun Kumar Ray,
📄 Page 12
Dean, School of Electronics Engineering, KIIT Deemed to be University, Bhubaneswar, and Dr. Anupam Shukla, Director, SVNIT Surat. I would like to thank Dr. Vidya Yeravdekar, Principal Director of Symbiosis Society and the Pro Chancellor of Symbiosis International University, Pune, Dr. Ramakrishnan Raman, Vice Chancellor of the Symbiosis International University, Pune, and Dr.Ketan Kotecha, Dean, Faculty of Engineering, Symbiosis International University, Pune, and Dr. Nitin Rakesh, Director, SIT Nagpur, for their advice, and encouragement throughout the preparation of the book. I would also like to thank Dr. Sanjeev Khandal, HOD, Department of Aeronautical Engineering, SGU Kolhapur, my well-wisher Dr. Prasenjeet D. Patil, Associate Professor, MIT ADT University, Pune, and my colleagues in Symbiosis Institute of Technology Nagpur for providing valuable suggestions and lots of encouragement throughout the project. I am thankful to Prof. Dr. N. Raju, Sr. Assistant Professor, SASTRA University, Thanjavur, Tamil Nadu, for his support, assistance during writing, and for his valuable suggestions. I would also like to thank Dr. Ravi M. Potdar, Sr. Associate Professor, BIT Durg, and Dr. Md. Khwaja Mohiddin, Associate Professor, BIT Raipur, for providing valuable suggestions and encouragement throughout the project. Writing a beautiful, well-balanced, and acquainted book is not a work of one or two days or a month; it takes a lot of time and patience, as well as hours of hard work. Many thanks to my family members, my parents, wife, children, and well-wishers for their kind support. Without them and their faith and support, writing this classic book would have remained just a dream. I also like to thank my students, who have always
📄 Page 13
been with me, for relating problems and finding solutions too. The perfection in any work does not come in a day. It needs a lot of effort, time, hard work, and sometimes, proper guidance. It is my privilege to thank Prof. (Dr.) Ram Dhekekar, Professor, Department of Electronics & Telecommunication Engineering, SSGMCE Shegaon, and Dr. C. G. Dethe, Director UGC Staff College Nagpur. Last but not the least, I would like to offer an extra special thanks to the staff at “BPB Publications Private Limited" for their insight and contribution in polishing this book. Most significantly, I want to thank Lord Ganesha for all of the work I was able to put into the book's preparation. I would not be as zealous as I am now if it weren't for God's amazing creation of the universe. For since the creation of the world God’s invisible qualities - his eternal power and divine nature - have been clearly seen, being understood from what has been made, so that men are without excuse." — Dr. Nilesh Bhaskarrao Bahadure
📄 Page 14
Preface The purpose of this book is to introduce readers with little to no programming experience in Python Graphical User Interface (GUI) to use Python binding for the GUI toolkit called PyQt5. A GUI application can be created in any programming language, whether VB.Net, C#.Net etc. In this book, we will see how to create a GUI application using PyQt5. The readers will get the foundational knowledge and skills necessary to start writing code for creating a GUI app in Python language. We will use a Graphical tool for creating user interfaces in Qt called Qt Designer. By mastering PyQt5, readers can apply this knowledge to solve real-world problems and create various useful applications according to their needs. The first part of the book covers PyQt5 library and the overall layout of Qt Designer tool. Then we will see some insights into layout management and the concept of event- driven programming and its implementation in the context of Python programming with the usage of the concept of signals and slots. Finally, in the later part of the book, we shall see an insight into various widgets related to buttons, container item views, container, input, and display widgets. This book covers a wide range of topics, from the basic definitions of different widgets to various solved examples with well-explanatory code. Overall, the book provides a solid foundation for beginners to start their journey for getting trained in Python GUI using the PyQt5 library along with the Qt Designer layout tool.
📄 Page 15
This book is divided into 9 chapters. Each chapter description is listed as follows. Chapter 1: Introduction to PyQt5 and Qt Designer Tool – This chapter will start by comparing powerful and cross-platform toolkit graphical PyQt5 with the tkinter library. You will learn how to install PyQt5 framework installation along with the creation of a basic GUI form using PyQt5 without and with using the class. We shall explore the components inside Qt Designer along with different pre- defined templates. In the latter half of the chapter, we will create a user credential app initially focusing on view in Qt Designer (.ui file, which is an XML file), then converting it into a python code (.py) using pyuic5 command and finally creating a new python file which will be importing the python code for user interface design and adding some useful logic to create a basic Login application for the user. Chapter 2: Getting Insights of Layout Management – will cover the concept on widgets placement using absolute positioning approach. We shall see widgets placement using layout classes where initially we will see how to organize widgets either horizontally or vertically using QBoxLayout class. We will explore how to arrange the widgets in a row side by side using QHBoxLayout with the usage of methods viz addStretch, addWidget, addLayout. Alternatively, we will look into arranging the widgets vertically with addStretch method using QVBoxLayout. Then we shall find out arranging widgets in a grid of rows and columns using QGridLayout. Also, we will look into creating an application using QFormLayout. In the end, we will be confident to create " User Credential App " application using absolute positioning , QBoxLayout, QGridLayout and QFormLayout class. Chapter 3: Getting Insights of Events, Signals and Slots – will explore the concept of event-driven
📄 Page 16
programming and how it is implemented in the context of Python programming using signals and slots. The above chapter will guide us through utilizing signals and slots to create and manage events. We will discover how to define signals and connect them to slots so that our program can respond to events in a useful way. We will also investigate various events and signals and how to use them to create interactive user interfaces or handle external inputs. Chapter 4: Getting Insights of Button Widgets in Qt Designer – will cover the concept of button widgets which are commonly used for creating interactive user interfaces and make them understand their properties, functionality, and customization options. By exploring the features and settings related to button widgets, user can effectively design and implement user-friendly interfaces in our Qt applications. Qt Designer offers a number of different button widgets, including CheckBox, Push Button, Tool Button, Radio Button, Command Link Button etc and shall explore description, properties, important methods , important signals and an application example with output display of each button widget in detail. The important properties of QObject, QWidget and QAbstractButton will be covered with images at the end as an addon information. Chapter 5: Getting Insights of Item Views in Qt Designer – will cover the concept of Item Views in Qt Designer which are commonly used for creating user interactive interfaces. We will look into their properties, functionality, and customization options. We will explore Qt Designer's item view widgets, like QTableView, QTreeView, and QListView, which are effective tools for presenting data in an organised and ordered way. User can use these widgets to display data in simple list formats (QListView), hierarchical tree structures (QTreeView), or rows and columns (QTableView).
📄 Page 17
Chapter 6: Getting Insights of Item Widgets (Item- Based) in Qt Designer – will cover the concept of Item Widgets in Qt Designer which are commonly used for creating interactive user interfaces. We shall look to understand their properties, functionality, customization options and also will gain a thorough grasp of how to create and operate item-based widgets within the Qt Designer environment. User will be able to create dynamic, interactive user interfaces using the power of item-based widgets and will also discover different features and characteristics to personalize the look and behavior of widgets viz list widget, tree widget and table widget. In order to facilitate user interaction and implement functionality, user will learn to manage the events and signals connected to item-based widgets. Chapter 7: Getting Insights of Containers in Qt Designer – will cover the concept of container widgets offered by Qt Designer, their features, and how to customize them to design aesthetically pleasing and user-friendly interfaces. User will investigate various container widget types and will obtain knowledge of the precise features and capabilities provided by each widget. They will get to know what container widgets are and how they work, its different types, its usage to create layouts and shall also explore customizing appearance of container widgets. Chapter 8: Getting Insights of Input Widgets in Qt Designer – will deal with concept of many input widgets available and how to utilize them effectively to create interactive user interfaces. Users will have a solid understanding of input widgets including QLineEdit, QSpinBox, QComboBox, QTextEdit etc. as well as their corresponding characteristics, functionality, and customization choices. They all shall experience the knowledge needed to incorporate these input widgets into their designs so that they may enter data, select options,
📄 Page 18
and interact with the program. The use of input validation methods, processing user input events, and linking signals and slots to accomplish required functionality are also covered for the benefit of the readers. In the end, they will be able to develop simple, user-friendly interfaces which will effectively collect user input and deliver a smooth user experience by mastering input widgets in Qt Designer. Chapter 9: Getting Insights of Display Widgets in Qt Designer – will explain the concept of display widgets in Qt Designer. Initially we will learn how to display static text or images using labels and how to change their font, color, alignment, and size. And then understand how labels can improve the GUI's visual presentation of information. We will examine the TextBrowser widget's features to learn how to display and control rich text content. Also, we will learn how to add hyperlinks, graphics, and formatting choices to text displays to make them dynamic and interactive. Next, we will explore how to add a calendar widget to our GUI application. We shall discover how to customize the calendar widget's look, structure, and behavior to meet specific application requirements. We will explore how to display numerical values, such as counters using the LCDNumber widget and also how to modify the LCDNumber widget's digit count, decimal accuracy, look, and style. Finally, we will look into exploring ProgressBar widget to show how a task or operation is progressing. We will learn how to dynamically update the progress bar based on our application.
📄 Page 19
Code Bundle and Coloured Images Please follow the link to download the Code Bundle and the Coloured Images of the book: https://rebrand.ly/s2nzbop The code bundle for the book is also hosted on GitHub at https://github.com/bpbpublications/Python-GUI-with- PyQt. In case there's an update to the code, it will be updated on the existing GitHub repository. We have code bundles from our rich catalogue of books and videos available at https://github.com/bpbpublications. Check them out! Errata We take immense pride in our work at BPB Publications and follow best practices to ensure the accuracy of our content to provide with an indulging reading experience to our subscribers. Our readers are our mirrors, and we use their inputs to reflect and improve upon human errors, if any, that may have occurred during the publishing processes involved. To let us maintain the quality and help us reach out to any readers who might be having difficulties due to any unforeseen errors, please write to us at : errata@bpbonline.com
📄 Page 20
Your support, suggestions and feedbacks are highly appreciated by the BPB Publications’ Family. Did you know that BPB offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.bpbonline.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at : business@bpbonline.com for more details. At www.bpbonline.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 BPB books and eBooks. Piracy If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at business@bpbonline.com with a link to the material. If you are interested in becoming an author If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit www.bpbonline.com. We have worked with thousands of developers and tech professionals, just like you, to help them share their insights with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Reviews Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions. We at BPB can understand what you think about our products, and our authors can see your feedback on their book. Thank you! For more information about BPB, please visit www.bpbonline.com. Join our book’s Discord space Join the book’s Discord Workspace for Latest updates, Offers, Tech happenings around the world, New Release and Sessions with the Authors:
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List