Music Album

Description:

The Python script allows the user to change settings for the camera, take a picture
and to save the picture.
First, the scripts sets the soft buttons to "Options" and "Exit".
From the Options menu, it is possible to choose:
- Take picture
- Save
- Settings
- Quit
Obvioiously, a picture is taken with the first command. With the second,
the user is prompted for a file name (by using a query text box).
When Settings is chosen, two tabs are opened.
From the first tab, flash settings can be set to auto, none and forced.
From the second tab, the image size can be set to 640x480 or 160x120.
In both cases, selctions lists are used to present the options to the user.
When a choice is made, the chosen value is stored in a global variable that
is read when an image is taken. Default values for the flash is none,
and for the screen size is 640x480.

#Assignment
from appuifw import *
from camera import *
picture=None
uflash=u'none'
usize=(640,480)
def TakePhoto():
global picture
global uflash
global usize
pic=take_photo(flash=uflash, size=usize)
picture=pic
old=app.body
app.body=canvas=Canvas()
canvas.blit(pic,scale=1)
def Save():
global picture
name=query(u'Name: ','text')
if picture is not None:
picture.save(u'c:\\Nokia\\Images\\' + name + '.jpg')
def setFlash():
global uflash
flashOptions=[u'forced', u'none', u'auto']
choice=selection_list(flashOptions)
if choice==None:
return
uflash=flashOptions[choice]
def setSize():
global usize
sizeOptions=[u'640x480', u'160x120']
sizeOptions2=[(640,480), (160,120)]
choice=selection_list(sizeOptions)
if choice==None:
return
usize=sizeOptions2[choice]
def showTab(idx):
if idx==0:
app.activate_tab(0)
setFlash()
elif idx==1:
app.activate_tab(1)
setSize()
def Settings():
app.set_tabs([u"Flash", u"Size"], showTab)
def Exit():
app.set_exit()
#appuifw.app.menu = [(u"Take Photo", TakePhoto), \
# (u"Save", Save),\
# (u"Settings", \
# ((u"Size", setSize), (u"setFlash", setFlash))),\
# (u"Exit", Exit)]
appuifw.app.menu = [(u"Take Photo", TakePhoto), \
(u"Save", Save),\
(u"Settings", Settings),\
(u"Exit", Exit)]

Download:

assignment.py

Department of Electronic Systems | Aalborg University | Niels Jernes Vej 12 | DK-9220 Aalborg | Denmark
Phone: (+45) 9635 8695 | Fax (+45) 9815 1583 | E-mail ies(at)ies.aau.dk
Copyright © 2006 Department of Electronic Systems

Last update:20-10-2006