| Reply | « Previous Thread | Next Thread » |
|
[code]# Copyright (c) 2006 Jurgen Scheible
# this script lets you create a simple application menu # NOTE: # press the options key in order to open the applicaion menu # when running the script! import appuifw from appuifw import * import camera from graphics import * from camera import * import e32 import audio from key_codes import * import ftplib global picselection global picselection1 global picselection2 global running global Image def exit_key_handler(): app_lock.signal() def item0(): class Keyboard(object): def __init__(self,onevent=lambda:None): self._keyboard_state={} self._downs={} self._onevent=onevent def handle_event(self,event): if event['type'] == appuifw.EEventKeyDown: code=event['scancode'] if not self.is_down(code): self._downs[code]=self._downs.get(code,0)+1 self._keyboard_state Code:
=1
elif event['type'] == appuifw.EEventKeyUp:
self._keyboard_state[event['scancode']]=0
self._onevent()
def is_down(self,scancode):
return self._keyboard_state.get(scancode,0)
def pressed(self,scancode):
if self._downs.get(scancode,0):
self._downs[scancode]-=1
return True
return False
keyboard=Keyboard()
running=1
switch = 1
appuifw.app.screen='normal'
img=Image.new((176,208))
def quit():
running=0
appuifw.app.set_exit()
def handle_redraw(rect):
canvas.blit(img)
canvas=appuifw.Canvas(event_callback=keyboard.handle_event, redraw_callback=handle_redraw)
appuifw.app.body=canvas
app.exit_key_handler=quit
screen_picture = camera.take_photo(size = (160,120))
while running:
if switch == 1:
screen_picture = camera.take_photo(size = (160,120))
img.blit(screen_picture,target=(8,10,168,130),scale=1)
handle_redraw(())
e32.ao_yield()
if keyboard.pressed(EScancodeLeftSoftkey):
switch = 1
if keyboard.pressed(EScancodeSelect):
switch = 2
e32.ao_yield()
image = camera.take_photo(size = (640,480))
filename=u'c:\\picture.jpg'
image.save(filename)
screen_picture =Image.open(u'c:\\picture.jpg')
e32.ao_yield()
def item1():
filename = 'c:\\boo.wav'
# define the recording part:
def recording():
global S
# open the sound file to be ready for recording and set an instance (S) of it
S=audio.Sound.open(filename)
# do the recording (has to be stopped by closing() function below)
S.record()
print "Recording on! To end it, select stop from menu!"
# define the playing part:
def playing():
global S
try:
# open the sound file to be ready for playing by setting an instance (S) of it
S=audio.Sound.open(filename)
# play the sound file
S.play()
print "Playing"
except:
print "Record first a sound!"
# stopping of recording / playing and closing of the sound file
def closing():
global S
S.stop()
S.close()
print "Stopped"
def exit_key_handler():
script_lock.signal()
appuifw.app.set_exit()
script_lock = e32.Ao_lock()
appuifw.app.title = u"Sound recorder"
# define the application menu
appuifw.app.menu = [(u"play", playing),
(u"record", recording),
(u"stop", closing),
(u"camera", item0)]
appuifw.app.exit_key_handler = exit_key_handler
script_lock.wait()
def item2():
def __exit__():
APP_LOCK.signal()
def doSave():
try:
f = open( 'c:\\yourFile.txt', 'wb' )
yourText = appuifw.app.body.get()
f.write( yourText.encode("utf-8") )
f.close
appuifw.note( u'Saved :)', 'conf' )
except IOError, e:
appuifw.note( u'Wrong file path!', 'error' )
except UnicodeError, e:
appuifw.note( unicode( e ), 'error' )
if __name__ == "__main__":
APP_LOCK = e32.Ao_lock()
appuifw.app.title = u'Text to file'
appuifw.app.exit_key_handler = __exit__
appuifw.app.body = appuifw.Text()
appuifw.app.menu = [( u'Save', doSave ),
( u'Exit', __exit__ )]
APP_LOCK.wait()
def item3():
picselection = 'c:\\fboo.wav' # name of file to be uploaded (path on phones hard drive)
picselection1 = 'c:\\picture.jpg' # name of file to be uploaded (path on phones hard drive)
picselection2 = 'c:\\yourFile.txt' # name of file to be uploaded (path on phones hard drive)
def fireupfile():
ftp = FTP('www.palplanet.net') # give servername
ftp.set_pasv('true')
ftp.login('xxx','xxxxx') # give login anonymous
ftp.cwd('public_html/wavfiles') # give correct folder where to store the image
F=open(picselection,'r')
F1=open(picselection1,'r')
F1=open(picselection1,'r')
F2=open(picselection2,'r')
ftp.storbinary('STOR fboo.wav',F,1024) # give name of image to be stored as URL
ftp.storbinary('STOR picture.jpg',F1,1024) # give name of image to be stored as URL
ftp.storbinary('STOR shata.txt',F2,1024) # give name of image to be stored as URL
ftp.quit()
F.close()
if appuifw.query(u"fire up stuff?","query") == True:
fireupfile()
def item4():
appuifw.note(u"Created By Mani ", "info")
app_lock = e32.Ao_lock()
appuifw.app.menu = [(u"Camera", item0),
(u"Audio", item1),
(u"Text", item2),
(u"Fire", item3),
(u"About", item4)]
appuifw.app.exit_key_handler = exit_key_handler
app_lock.wait()
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Camera snapshot on 3250 | stefanosanna | Mobile Java Media (Graphics & Sounds) | 0 | 2006-05-04 15:31 |
| screen rotating affect camera function? | whitewinds | Symbian Media (Graphics & Sounds) | 5 | 2006-03-20 21:41 |
| Waiting for capturing and saving the image by camera | sjsahu | General Symbian C++ | 2 | 2006-03-08 12:36 |
| CMdaAudioOutputStream Not working with EXEDLL target | fnagaton | General Symbian C++ | 6 | 2005-10-03 06:51 |
| embedable camera application?? | zhengyu97 | General Symbian C++ | 0 | 2005-04-22 12:09 |