logo资料库

kivy开发app.pdf

第1页 / 共139页
第2页 / 共139页
第3页 / 共139页
第4页 / 共139页
第5页 / 共139页
第6页 / 共139页
第7页 / 共139页
第8页 / 共139页
资料共139页,剩余部分请下载后查看
Copyright
Table of Contents
Preface
Who Should Read This Book
Technology Used in This Book
Conventions Used in This Book
Using Code Examples
Safari® Books Online
How to Contact Us
Acknowledgments
Chapter 1. Introducing Kivy
Dependencies: The Hard Part
Installing on Mac OS
Installing on Windows
Writing Code: The Easy Part
Introducing the KV Language
User Interface Design
Widgets
The KV Language Root Widget
Creating a Custom Widget
Adjusting Widget Size
File It All Away
Chapter 2. Events and Properties
What Is an Event?
Adding Logic to a Custom Widget
Responding to Events
Accessing Properties of KV Language Widgets
Populating the Search Result List
File It All Away
Chapter 3. Manipulating Widgets
A More Extensible Root Widget
ListView Adapters
Responding to ListView Item Events
Swappable Widgets
Switching Forms
File It All Away
Chapter 4. Iterative Development
Improving the Add Location Form
Caching Widgets
Storing Actual Locations and Converting Arguments
Retrieving Weather Data
File It All Away
Chapter 5. Kivy Graphics
A Conditions Widget
Dynamic Conditions
Abstracting Common Widgets
Basic Animation
Using Icons Instead
File It All Away
Chapter 6. Kivy Storage
Maintaining a List of Locations
Storing the Location List
The User Settings Dialog
File It All Away
Chapter 7. Gestures
The Forecast Tab
Recording Gestures
Touch Events
Recognizing Gestures
Firing Events
File It All Away
Chapter 8. Advanced Widgets
Carousel
The ModalView Widget
Completing the Refactor
Adding an Action Bar
File It All Away
Chapter 9. Releasing to Android and iOS
Getting Buildozer
Deploying Your Application
Deploying to iOS
Android Bonus: Accessing the GPS
Keeping It Running
File It All Away
Index
About the Author
Creating Apps in Kivy Dusty Phillips
Creating Apps in Kivy by Dusty Phillips Copyright © 2014 Dusty Phillips. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or corporate@oreilly.com. Editors: Meghan Blanchette and Rachel Roumeliotis Production Editor: Nicole Shelby Copyeditor: Rachel Monaghan Proofreader: Rachel Head Indexer: Judy McConville Cover Designer: Randy Comer Interior Designer: David Futato Illustrator: Rebecca Demarest April 2014: First Edition Revision History for the First Edition: 2014-04-08: First release See http://oreilly.com/catalog/errata.csp?isbn=9781491946671 for release details. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Creating Apps in Kivy, the image of a kiang, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN: 978-1-491-94667-1 [LSI]
Table of Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii 1. Introducing Kivy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Dependencies: The Hard Part 2 Installing on Mac OS 3 Installing on Windows 4 Writing Code: The Easy Part 5 Introducing the KV Language 6 User Interface Design 7 Widgets 9 The KV Language Root Widget 10 Creating a Custom Widget 12 Adjusting Widget Size 13 File It All Away 18 2. Events and Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 What Is an Event? 21 Adding Logic to a Custom Widget 22 Responding to Events 23 Accessing Properties of KV Language Widgets 24 Populating the Search Result List 27 File It All Away 32 3. Manipulating Widgets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 A More Extensible Root Widget 35 ListView Adapters 36 Responding to ListView Item Events 39 Swappable Widgets 41 Switching Forms 43 iii
File It All Away 44 4. Iterative Development. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Improving the Add Location Form 46 Caching Widgets 46 Storing Actual Locations and Converting Arguments 49 Retrieving Weather Data 53 File It All Away 56 5. Kivy Graphics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 A Conditions Widget 59 Dynamic Conditions 61 Abstracting Common Widgets 65 Basic Animation 67 Using Icons Instead 70 File It All Away 71 6. Kivy Storage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Maintaining a List of Locations 73 Storing the Location List 75 The User Settings Dialog 77 File It All Away 82 7. Gestures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 The Forecast Tab 83 Recording Gestures 87 Touch Events 89 Recognizing Gestures 91 Firing Events 92 File It All Away 93 8. Advanced Widgets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Carousel 95 The ModalView Widget 97 Completing the Refactor 99 Adding an Action Bar 101 File It All Away 103 9. Releasing to Android and iOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Getting Buildozer 105 Deploying Your Application 106 Deploying to iOS 113 iv | Table of Contents
Android Bonus: Accessing the GPS 115 Keeping It Running 117 File It All Away 117 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Table of Contents | v
分享到:
收藏