| Reply | « Previous Thread | Next Thread » |
|
Hello everyone.,
This is the sourcecode for my project.. # 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! from appuifw import * from graphics import * import camera import e32 import audio from key_codes import * from ftplib import FTP global picselection global picselection1 global picselection2 global running 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"Upload", item3)] 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','xxxxxx') # 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() The filename is proj.py I'm using py2sis to create a sis file as c:\>py2sis proj.py proj.sis --uid=0x0FF11111 --appname=project After i push the sis file and install it the app opens and exits with a blank screen.. please suggest..
Last edited by asteroidm : 2007-05-04 at 11:46.
|
|
You're missing "import appuifw"
|
|
Hi asteroidm and welcome to the forum
![]() Please next time you post some source code use the CODE tag (# button) to keep the source indentation and visibility. As Jukka said before you forgot to import appuifw. You imported everything from it but not the module itself. So ether you change from appuifw import * by import appuifw or you remove all appuifw. in your script. Now for the sis I had one similar problem because PyS60 was installed on the E: drive. Installing PyS60 and the libraries on C: fixed the problem. Happy Pythoning to you ![]() LFD Devices: Nokia E61 3rd Edition - pys60 1.4.0 Tips and modules: http://www.lfdm.net/thesis |
|
hello lfd and jukka..
i tried by importing appuifw..and the app successfully opened but now the camera shows a white blank page and the ftp part too doesnt work!.. any help |
|
Hi asteroidm,
Please repost you source within CODE tags, there are things I don't really get. LFD Devices: Nokia E61 3rd Edition - pys60 1.4.0 Tips and modules: http://www.lfdm.net/thesis |
|
import appuifw
from graphics import * import camera import e32 import audio from key_codes import * from ftplib import FTP global picselection global picselection1 global picselection2 global running [code] 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()
Code:
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"Upload", item3)]
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','xxxx') # 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()
![]() This is the code buddy.. i have installed the latest version of pys60 on N70 onto the phone memory.. the camera shows a blank screen.
Last edited by asteroidm : 2007-05-04 at 18:45.
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Create .sis File Failed Help Me Please!!!! | tkd82 | Symbian Tools & SDKs | 1 | 2006-08-31 13:23 |
| S60 theme questions | Nokian_Spb | Symbian Media (Graphics & Sounds) | 3 | 2006-08-17 07:11 |
| Help !about .mbm的形成 | wangguoshui | Symbian | 4 | 2004-12-23 04:37 |
| Nokia 6600: Unable to delete a .SIS file in my INBOX! | sneakerpimp | General Symbian C++ | 2 | 2004-01-03 10:38 |
| Opening WAP browser on local file | nawkboy | General Symbian C++ | 4 | 2003-09-10 23:18 |