所需积分/C币:10 2017-06-05 13:20:00 8.77MB PDF
收藏 收藏

Python GUI Programming Cookbook Copyright 2015 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, 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: November 2015 Production reference: 1261115 Published by Packt Publishing Ltd 35 Livery Street Birmingham B3 2PB, UK sBN978178528-3758 Credits Au uthor Project Coordinator Burkhard A meier Shweta h. birwatkar Reviewers Proofreader Joy bindroo Safis Editing Peter bouda Joseph re Ind Priya sane Commissioning Edite Nadeem e Graphics Kirk penha Acquisition Editor Vivek anantharaman Production Coordinator Komal Ramchand Content Development Editor Sumeet sawant Cover Work Komal Ramchandan Technical editor Pramod Ke Copy Editor Janbal dharmaral About the Author Burkhard A Meier has more than 15 years of professional experience working in the software industry as a software tester and developer, specializing in software test automation development, execution, and analysis. He has a very strong background in SQL relational database administration, the development of stored procedures, and debugging code While experienced in Visual Studio. NET C#, visual Test, TestComplete, and other testing languages (such as C/C++), the main focus of the author over the past two years has been developing test automation written in Python 3 to test the leading edge of FLIR ONE infrared cameras for iPhone and android smart phones as well as handheld tablets Being highly appreciative of art, beauty, and programming, the author developed gUls in C# and Python to streamline everyday test automation tasks, enabling these automated tests to run unattended for weeks, collecting very useful data to be analyzed and automatically plotted into graphs and e-mailed to upper management upon completion of nightly automated test runs His previous jobs include working as a senior test automation engineer and designer for Info Genesis(now Agilysys), QAD, In Touch Health, and presently, FLIR Systems YoucangetintouchwithhimthroughhisLinkedinaccounthttps://www.linkedincom pub/burkhard-meier/5/246/296. I would like to thank all truly great artists such as Leonardo da vinci, charles Baudelaire, Edgar Poe, and so many more for bringing the presence of beauty into our human lives. this book is about creating very beautiful GUls written in the Python programming language and it was inspired by these truly great artists I would like to thank all of the great people that made this book possible Without any of you, this book would only exist in my mind. I would like to especially thank all of my editors at Packt Publishing: vivek, Arwa, Sumeet, Pramod, Nikhil and so many more. would also like to thank all of the reviewers of the code of this book. without them this book would be harder to read and apply to real-world problems. Last but not least, I like to thank my ife, our daughter, and our parents for the emotional support they provided so successfully during the writing of this book. I also like to give thanks to the creator of this very beautiful and powerful programming language that Python truly is. Thank you Guido About the reviewers Joy bindroo holds a bachelor's degree in computer science and engineering. He is currently pursuing his post-graduate studies in the field of information management He is a creative person and enjoys working on Linux platform and other open source technologies. He enjoyswritingaboutPythonandsharinghisideasandskillsonhiswebsitehttp://www joybindroo. com/. He likes to sketch, write poems, listen to music, and have fun with his friends in his free time I would like to thank my family, teachers, and friends for always encouraging and supporting me. I'm most thankful to lord shiva who enables me to achieve greater heights Peter Bouda works as a senior web developer for mAj digital and is a specialist in full stack Java Script applications based on Loop Back and angularIS. He develops python Guls for companies and research projects since 2003 and wrote a german book, PyQt und PySide-GUI-und Anwendungsentwicklung mit Python und Qt, on Python GUI development, which was published in 2012. Currently, he is getting crazy with embedded and open hardware platforms and is working on a modular game console based on open hardware Joseph Rex is a full stack developer with a background in computer security. he has worked on Python GUI products and some Cll programs to experiment with information security. He came out of security to web development and developed a passion for rails and JavaScript MVC frameworks after working on several projects using jQuery. He has been in the web industry for 3 years, building web applications and mobile apps. He has also written articles on security for Info sec Institute and has written some scripts to back them up. He has to his credit several personal experimental projects written in Python www.packtpubcom Support files, eBooks discount offers, and more Did you know that Packt offers e Book versions of every book published, with PDF and ePub filesavailableYoucanupgradetotheebooKversionatwww.PacktPub.comandasaprint book customer, you are entitled to a discount on the e Book copy Get in touch with us at service@packtpub com for more details Atwww.packtpub.comyoucanalsoreadacollectionoffreetechnicalarticlessignupfor a range of free newsletters and receive exclusive discounts and offers on Packt books and e Books 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 Why Subscribe? Fully searchable across every book pu blished by packt Copy and paste, print, and bookmark content On demand and accessible via a web browser Free Access for packt account holders IfyouhaveanaccountwithPacktatwww.packtpub.comyoucanusethistoaccess PacktLib today and view 9 entirely free books Simply use your login credentials for immediate access Table of contents Preface Chapter 1: Creating the GUl Form and Adding widgets Introduction Creating our first Python GUI Preventing the GUl from being resized Adding a label to the gui form Creating buttons and changing their text property 1124679 Text box widgets Setting the focus to a widget and disabling widgets 11 Combo box widgets 12 Creating a check button with different initial states 14 Using radio button widgets 16 Using scrolled text widgets 18 Adding several widgets in a loop 20 Chapter 2: Layout Management 23 Introduction 23 Arranging several labels within a label frame widget 24 Using padding to add space around widgets 26 How widgets dynamically expand the GUI 28 Aligning the GUI widgets by embedding frames within frames 32 creating menu bars 36 Creating tabbed widgets 41 Using the grid layout manager 46 Table of contents Chapter 3: Look and Feel customization 49 Introduction 49 Creating message boxes-information, warning, and error 50 How to create independent message boxes 53 How to create the title of a tkinter window forn 56 Changing the icon of the main root window 57 Using a spin box control 8 Relief, sunken, and raised appearance of widgets 61 Creating tooltips using Python 63 How to use the canvas widget 67 Chapter 4: Data and classes 69 Introduction 69 How to use StringVar0 69 How to get data from a widget 73 Using module-level global variables 75 How coding in classes can improve the GUl 79 Writing callback functions Creating reusable GUI components 86 Chapter 5: Matplotlib Charts 91 Introduction 91 Creating beautiful charts using Matplotlib 92 Matplotlib- downloading modules using pip 94 Matplotlib-downloading modules with whl extensions 98 Creating our first chart 100 Placing labels on charts 102 How to give the chart a legend 106 Scaling charts 109 Adjusting the scale of charts dynamically 112 Chapter 6: Threads and Networking 117 Introduction 117 How to create multiple threads 118 Starting a thread 121 Stopping a thread 125 How to use queues 128 Passing queues among different modules 133 Using dialog widgets to copy files to your network 136 Using TCP/IP to communicate via networks 145 Using URLOpen to read data from websites 147 Table of contents Chapter 7: Storing Data in Our MySQL Database via Our GUl 153 Introduction 153 Connecting to a MysQL database from Python 154 Configuring the My SQL connection 157 Designing the Python GUI database 161 Using the SQL INSERT command 168 Using the SQL UPDATE command 172 Using the SQL DELETE command 177 Storing and retrieving data from our MysQL database 181 Chapter 8: Internationalization and Testing 187 Introduction 187 Displaying widget text in different languages 188 Changing the entire GUl language all at once 191 Localizing the GUI 196 Preparing the GUI for internationalization 201 How to design a GUI in an agile fashion 204 Do we need to test the gui code? 208 Setting debug watches 212 Configuring different debug output levels 216 Creating self-testing code using Python's main section 220 Creating robust GUls using unit tests 224 How to write unit tests using the Eclipse Pydev IDE 229 Chapter 9: Extending Our GUl with the wxPython Library 235 Introduction 235 How to install the wXPython library 236 How to create our GUl in wxPython 239 Quickly adding controls using wXPython 244 Trying to embed a main wxPython app in a main tkinter app 251 Trying to embed our tkinter GUI code into wXPython 253 How to use Python to control two different GUl frameworks 256 How to communicate between the two connected guls 260 Chapter 10: Creating Amazing 3D GUls with PyOpenGL and Py GLet 265 Introduction 265 PyOpen GL transforms our GUI 266 Our gul in 3DI 270 Using bitmaps to make our GUl pretty 275 Py GLet transforms our GUI more easily than Pyopen GL 279 Our GUI in amazing colors 283 Creating a slideshow using tkinter 286 i

试读 127P Python.GUI.Programming.Cookbook
立即下载 低至0.43元/次 身份认证VIP会员低至7折
wsxiaoping3 很好的资料啊,正需要啊
tograk_1 确实很好啊
关注 私信
    Python.GUI.Programming.Cookbook 10积分/C币 立即下载

    试读结束, 可继续阅读

    10积分/C币 立即下载 >