Wiley_Mobile_Python_Rapid_Prototyping_of_Applications_on_the_Mobile_Platform.pdf

(3971 KB) Pobierz
994555789.009.png
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
994555789.010.png 994555789.011.png 994555789.012.png 994555789.001.png 994555789.002.png 994555789.003.png 994555789.004.png 994555789.005.png 994555789.006.png 994555789.007.png 994555789.008.png
Copyright ¤ 2007
John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester,
West Sussex PO19 8SQ, England
Telephone (
+
44) 1243 779777
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 (
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.
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
Zgłoś jeśli naruszono regulamin