实例介绍
本书适用于具有Python编程初步知识的中高级程序员和开发人员,,基于Qt5和python进行图像界面编程。对于希望在Python中构建功能齐全的基于GUI的应用程序的培训师,教师和软件开发人员而言,本书非常有用。
Qt5 Python GUI Programming Cookbook Copyright o 2018 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 author, nor Packt Publishing 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 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 Commissioning editor: Richa Tripathi Acquisition Editor: Alok dhuri Content Development editor: Zeeyan pinheiro Technical Editor: Vibhuti Gawde Copy Editor: Safis Editing Project Coordinator: Vaidehi Sawant Proofreader: Safis Editing Indexer: Rekha nair Graphics: Jason monteiro Production Coordinator: Nilesh mohite First published: July 2018 Production reference: 1270718 Published by Packt Publishing Ltd Iver 35 Livery street Birmingham B 3 2PB, UK ISBN978-1-78883-100-0 www.packtpub.com I am thankful to my family-my small world: Anushka (my wife)and my two little darlings, Chirag and Naman, for allowing me to work on the book even during time that I was supposed to spend with them Mapt mapt.lO Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website Why subscribe? Spend less time learning and more time coding with practical ebooks and videos from over 4, 000 industry professionals Improve your learning with Skill Plans built especially for you Get a free ebook or video every month e mapt is fully searchable Copy and paste, print, and bookmark content PacktPub, com Did you know that Packt offers eBook versions of every book published, with PDF and epubfilesavailableYoucanupgradetotheebookversionatwww.Packtpub.comandasa print book customer, you are entitled to a discount on the e book copy. Get in touch with us at servicegpacktpub com for more details Atwww.packtpub.comyoucanalsoreadacollectionoffreetechnicalarticlessignupfora range of free newsletters and receive exclusive discounts and offers on packt books and eBookS Contributors About the author B.M. Harwani is the founder and owner of Microchip Computer Education(MCe), based in Ajmer, India. He graduated with a Be in computer engineering from the University of Pune and also has a C level (masters diploma in computer technology) from DOEACC, Government of India. Having been involved in the teaching field for over 20 years, he has developed the art of explaining even the most complicated topics in a straightforward and easily understandable fashion He is also a renowned speaker and the author of several books. To learn more, visit his blog, a site that helps programmers a big thank you to the entire editorial team at Packt, who worked tirelessly to produce this book. Really, i enjoyed working with each of you I should not forget to thank my dear students, who have been a good teacher for me as they make me understand the basic problems they face in a subject and enable me to directly hit those topics. The endless interesting queries from my students help me write books with a practical approach. About the reviewers Marcus ottosson is a company director, software developer and artist with a decade of experience in the film and visual effects industry he has built countless user interfaces and tools with Python and Qt for projects such as Marvels Doctor Strange and Alfonso Cuaron's Gravity. He has written several Python frameworks for use in the creation of film and games, such as Pyblish and Avalon, along with PyQt, a compatibility wrapper around all the available bindings of Qt for Python Sivan Grunberg has close to 20 years of multidisciplinary IT expertise and a razor-sharp eye for quality. A long-time open source devotee, his contributions can be found, literally, all over open source. He has been utilizing the python ecosystem for r&d endeavors ever since it was pitched to him by The sabdFl and ubuntu. alongside shir a product content, and operations expert, he runs Vitakka co, providing infrastructure consulting and coding solutions in all-things digita My amazing family, Eric, Helena, Shir, Moshik, and the debian/ubuntu, Python, GNOME, and KdE communities--without you, these lines would have never been ritten Packt is searching for authors like you IfyoureinterestedinbecominganauthorforPackt,pleasevisitauthorspacktpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight 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 Table of contents Preface Chapter 1: Creating a User Interface with Qt components Introduction PyQt Ways of creating GUI applications 8899 Displaying a welcome message Understanding the Label widget Methods 12 Understanding the Line Edit widget Methods Understanding the push button widget 13 How to do it 14 How it works Using the Radio Button widget 18 Understanding Radio Button 19 Methods 19 Signal description 19 How to do it 20 How it works 22 Grouping radio buttons 22 Getting ready 23 How to do it 23 How it works 26 Displaying options in the form of checkboxes 27 Getting ready 27 Method application 27 Signal description 28 How to do it 28 How it works 30 Displaying two groups of checkboxes 31 Getting ready 31 How to do it 31 How it works 34 Chapter 2: Event Handling -Signals and Slots 35 Introduction 35 Using Signal/Slot Editor 36 How to do it 36 Copying and pasting text from one Line Edit widget to another 38 Getting read 39 Table of contents How to do it 39 How it works 44 Converting data types and making a small calculator 45 How to do it How it works Using the Spin Box widget 51 Getting read 51 How to do it 52 How it works 54 Using scrollbars and sliders 55 Getting ready 55 How to do it 58 Howⅰ t works 59 Using List Widget 61 Getting ready 61 How to do it 62 How it works 64 Selecting multiple list items from one List widget and displaying them in another 65 How to do it 65 How it works 67 Adding items into list widget 68 How to do it 68 How it works 69 Performing operations in List Widget 70 Getting ready 70 Methods provided by the QListWidgetitem class 70 How to do it 71 How it works 73 Using the Combo Box widget 77 How to do it 78 How it works 80 Using the Font Combo Box widget 81 Getting read 81 How to do it 82 How it works 83 Using the Progress Bar widget 84 Getting read 85 How to do it 85 How it works 87 Chapter 3: Working with Date and Time 88 Displaying LCD digits 88 Using Timers 89 Using the QTime class 89 Table of contents Displaying system clock time in LCD-like digits 90 How to do it 90 Howⅰ t works. 91 Displaying the date selected by the user from Calendar Widget 92 Getting ready Displaying a calendar 93 Using the QDate class 94 Using the date edit widget 95 How to do 96 How it works 97 Creating a hotel reservation form 99 99 How to do it 101 How it works 104 Displaying tabular data using Table Widget 105 Getting ready 105 Table Widget 105 The QTable Widgetitem class 105 How to do it 106 How it works 108 Chapter 4: Understanding OOP Concepts 109 Object-oriented programming 109 Creating a class 109 Using the built-in class attributes 110 Accessing class variables in instance methods 111 Instances 111 Using classes in GUI 113 How to do it 113 How it works Making the application more elaborate 116 Inheritance 119 Types of inheritance 119 Using single inheritance 120 Getting read 120 How to do it 121 How it works 123 Using multilevel inheritance 125 Getting ready 125 How to do it 126 How it works 129 Using multiple inheritance 131 Getting ready 132 How to do it 132 How it works 135 Chapter 5: Understanding Dialogs 138 【实例截图】
【核心代码】
标签:
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论