Mobile Python - Rapid Prototyping of Applications on the Mobile Platform (2007).pdf

(3071 KB) Pobierz
519135622 UNPDF
Mobile Python
Rapid Prototyping of Applications
on the Mobile Platform
J urgen Scheible and Ville Tuulos
Reviewedby
Panos Asproulis, Mal Minhas, Tim Ocock, Mark Shackman,
Ian Weston
HeadofSymbianPress
Freddie Gjertsen
ManagingEditor
Satu McNabb
519135622.001.png
Copyright ¤ 2007
John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester,
West Sussex PO19 8SQ, England
Telephone (
+
44) 1243 779777
44) 1243 770620.
Designations used by companies to distinguish their products are often claimed as trademarks. All
brand names and product names used in this book are trade names, service marks, trademarks or
registered trademarks of their respective owners. The Publisher is not associated with any product or
vendor mentioned in this book.
This publication is designed to provide accurate and authoritative information in regard to the subject
matter covered. It is sold on the understanding that the Publisher is not engaged in rendering
professional services. If professional advice or other expert assistance is required, the services of a
competent professional should be sought.
+
OtherWileyEditorialOffices
John Wiley & Sons Inc., 111 River Street, Hoboken, NJ 07030, USA
Jossey-Bass, 989 Market Street, San Francisco, CA 94103-1741, USA
Wiley-VCH Verlag GmbH, Boschstr. 12, D-69469 Weinheim, Germany
John Wiley & Sons Australia Ltd, 42 McDougall Street, Milton, Queensland 4064, Australia
John Wiley & Sons (Asia) Pte Ltd, 2 Clementi Loop #02-01, Jin Xing Distripark, Singapore 129809
John Wiley & Sons Canada Ltd, 6045 Freemont Blvd, Mississauga, Ontario, L5R 4J3, Canada
Wiley also publishes its books in a variety of electronic formats. Some content that appears
in print may not be available in electronic books.
Anniversary Logo Design: Richard J. Pacifico
BritishLibraryCataloguinginPublicationData
A catalogue record for this book is available from the British Library
ISBN: 978-0-470-51505-1
Typeset in 10/12pt Optima by Laserwords Private Limited, Chennai, India
Printed and bound in Great Britain by Bell & Bain, Glasgow
This book is printed on acid-free paper responsibly manufactured from sustainable forestry
in which at least two trees are planted for each one used for paper production.
Email (for orders and customer service enquiries): cs-books@wiley.co.uk
Visit our Home Page on www.wileyeurope.com or www.wiley.com
All Rights Reserved. No part of this publication may be reproduced, stored in a retrieval system or
transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or
otherwise, except under the terms of the Copyright, Designs and Patents Act 1988 or under the terms of
a licence issued by the Copyright Licensing Agency Ltd, 90 Tottenham Court Road, London W1T 4LP,
UK, without the permission in writing of the Publisher. Requests to the Publisher should be addressed to
the Permissions Department, John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West
Sussex PO19 8SQ, England, or emailed to permreq@wiley.co.uk, or faxed to (
Contents
Contributors
ix
About the Authors
xi
Authors’ Acknowledgments
xiii
Symbian Press Acknowledgments
xvii
Forewords
xix
1 Introduction and Basics
1
1.1 Why Does Python Make a Difference?
3
1.2 How to Use this Book
4
1.3 Who Is this Book For?
5
1.4 What Are Symbian OS, S60 and Python for S60?
6
1.5 Python Terminology in this Book
7
1.6 Democratizing Innovation on the Mobile Platform
8
1.7 The Process of Rapid Prototyping with Python S60
10
1.8 Summary
11
2 Getting Started
13
2.1 Installing Python for S60 on 3rd Edition Devices
14
2.2 Installing Python for S60 on 2nd Edition Devices
21
2.3 Writing a Program in Python for S60
27
2.4 White Space in Python Code
28
2.5 Troubleshooting
29
2.6 Summary
30
vi
CONTENTS
3 Graphical User Interface Basics
31
3.1 Using Modules
31
3.2 Native UI Elements – Dialogs, Menus and Selection
Lists
32
3.3 Messages
45
3.4 Summary
47
4 Application Building and SMS Inbox
49
4.1 Functions
49
4.2 Application Structure
52
4.3 String Handling
60
4.4 SMS Inbox
64
4.5 SMS Game Server
70
4.6 Summary
76
5 Sound, Interactive Graphics and Camera
77
5.1 Sound
77
5.2 Keyboard Keys
84
5.3 Graphics
92
5.4 Camera
100
5.5 Mobile Game: UFO Zapper
104
5.6 Summary
110
6 Data Handling
111
6.1 File Basics
112
6.2 Reading and Writing Text
117
6.3 Local Database
121
6.4 GSM and GPS Positioning
123
6.5 Vocabulector: A Language-Learning Tool
127
6.6 Summary
131
7 Bluetooth and Telephone Functionality
133
7.1 Bluetooth Pairing
134
7.2 OBEX and RFCOMM
134
7.3 Phone-to-Phone Communication
136
7.4 Phone-to-PC Communication
141
7.5 Communication with GPS and Other Devices
148
7.6 Telephone Functionality and Contacts
151
7.7 System Information
152
7.8 Summary
154
8 Mobile Networking
155
8.1 Simple Web Tasks
156
8.2 Setting up the Development Environment
158
CONTENTS
vii
8.3 Communication Protocols
166
8.4 Server Software
172
8.5 Pushing Data to a Phone
177
8.6 Peer-to-Peer Networking
183
8.7 Using a Phone as a Web Service
193
8.8 Summary
197
9 Web Services
199
9.1 Basic Principles
200
9.2 MopyMaps! Mobile Yahoo! Maps
201
9.3 EventFu: Finding Eventful Events
207
9.4 InstaFlickr: Shoot and Upload Photos to Flickr
215
9.5 Summary
224
10 Effective Python for S60
227
10.1 Powerful Language Constructs
227
10.2 Introspection
231
10.3 Custom Modules and Automatic Updating
234
10.4 Program Patterns
239
10.5 Summary
241
11 Combining Art and Engineering
245
11.1 MobiLenin
245
11.2 Manhattan Story Mashup
252
11.3 MobileArtBlog – Image-Composition Tool
256
11.4 ArduinoBT Micro-Controller Board
261
11.5 Controlling Max/MSP with a Phone
266
11.6 OpenSound Control
273
11.7 Robotics
274
11.8 Summary
277
Appendix A: Platform Security
279
Appendix B: Bluetooth Console
289
Appendix C: Debugging
295
Appendix D: How to Use the Emulator
301
References
303
Glossary
305
Examples
309
Zgłoś jeśli naruszono regulamin