def getwd(self): self.pwd = self.ftp.pwd() s = StringIO.StringIO() self.ftp.retrbinary('LIST', s.write) s.seek(0) li = s.read() s.close() fs = [] l = [] a = li.split("\r\n") folder = ui.Icon(u(self.db['icons']), 115, 116) d = f = [] l.append((u'..', folder)) self.amt = len(a) - 1 if li: dirs = [] files = [] for I in range(0, self.amt): fs.append([I]) i = a[I].split(" ") for p in range(len(i)): if not i[p] == '': if p == 0: i[p] = list(i[p]) fs[I].append(i[p]) fs[I][9] = ' '.join(fs[I][9:]) if fs[I][1][0] == "d": dirs.append((u(fs[I][9]), folder)) else: files.append( (u(fs[I][9]), ui.Icon(u(self.db['icons']), 57, 58))) I = I - 1 l += dirs + files self.fs = fs return l
def list_content(): global Sayflags icons = [ appuifw.Icon(u"z:\\resource\\apps\\avkon2.mif", 16506, 16507), appuifw.Icon(u"z:\\resource\\apps\\avkon2.mif", 16504, 16505) ] # unchecked, unchecked return map(lambda s, f: tuple([s, icons[f]]), clock_names(), Sayflags)
def createListDoubleLineWithIcon(): appuifw.app.body = None icon1 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 28, 29) icon2 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm ", 40, 41) myList = [(u'Sygnal', u'2/7', icon1), (u'Battery', u'5/7', icon2)] listbox = appuifw.Listbox(myList, lbox_observe) appuifw.app.body = listbox
def listapps(): global entries, limit lapp = applist.applist() lapp1 = [(el[1], el[0]) for el in lapp] lmbm = [] entries = [] c = 0 uidno = 0xa89fd974 puz2 = geticon.get(uidno, (50, 50)) ipuz = Image.from_cfbsbitmap(puz2[0]) mpuz = Image.from_cfbsbitmap(puz2[1]) sd = 0 for el in lapp1: try: i2 = geticon.get(el[1], (50, 50)) except: print 'p: ', el try: i = Image.from_cfbsbitmap(i2[0]) imask = Image.from_cfbsbitmap(i2[1]) except: print i2[0] i = ipuz imask = mpuz lmbm.append(i) lmbm.append(imask) entries.append((el[0], unicode(hex(el[1])), appuifw.Icon(u'd:\\iapps.mbm', sd, sd + 1))) sd += 2 c += 1 if c >= limit: break multimbm.create(u'd:\\iapps.mbm', lmbm)
def handle(self): c = app.body.current() if c == 0: self.conscr() elif c == 1: self.exit(self.mainscr) self.interface = [] sys_drives = ['C:', 'D:', 'Z:'] for d in e32.drive_list(): if d in sys_drives: icon = ui.Icon(u(self.db.get('icons')), 397, 398) else: icon = ui.Icon(u(self.db.get('icons')), 395, 396) self.interface.append((u(d), icon)) app.body = self.disp(self.file) elif c == 2: self.settings() elif c == 3: self.setup() else: pass
def getwd(self,dirname=None): if not dirname:self.pwd=dr=self.ftp.pwd() else:dr=dirname self.l.addtext(u'Retrieving files', 1) s=StringIO.StringIO();self.ftp.retrbinary('LIST '+dr,s.write);s.seek(0);li=s.read();s.close(); fs=[];l=[];a=li.split("\r\n");folder=ui.Icon(u(self.get_db('icons')), 115, 116);d=f=[];l.append((u'..', folder));self.amt=len(a)-1 if li: dirs=[];files=[] for I in range(0, self.amt): fs.append([I]);i=a[I].split(" ") for p in range(len(i)): if not i[p]=='': if p==0:i[p]=list(i[p]) fs[I].append(i[p]) fs[I][9]=' '.join(fs[I][9:]) if fs[I][9]=='.' or fs[I][9]=='..':pass else: if fs[I][1][0]=="d":dirs.append((u(fs[I][9]),folder)) else:files.append((u(fs[I][9]),ui.Icon(u(self.get_db('icons')), 57, 58))) I=I-1;l+=dirs+files self.fs=fs;return l
def get_checkbox(a_value): ''' Checkbox icon: selected or not ''' global icon_on, icon_off # Create only once, reuse after that if not icon_on: # See avkon2.mbm content (old version) # http://alindh.iki.fi/symbian/avkon2.mbm/ try: # webkit checkbox looks better, but might not exist icon_off = appuifw.Icon(u"z:\\resource\\apps\\webkit.mbm", 12, 31) icon_on = appuifw.Icon(u"z:\\resource\\apps\\webkit.mbm", 13, 32) except: # Counting on avkon2 to be there, hopefully with checkbox icon_off = appuifw.Icon(u"z:\\resource\\apps\\avkon2.mbm", 103, 104) icon_on = appuifw.Icon(u"z:\\resource\\apps\\avkon2.mbm", 109, 110) if a_value: return icon_on else: return icon_off
def generate_listbox_entries(with_icons=False, list_type='single'): entries = [] icon = None icon_file = u"z:\\resource\\apps\\avkon2.mbm" for icon_id in range(0, 200, 2): row1 = u"Icon: " + unicode(str(icon_id)) row2 = u"Mask: " + unicode(str(icon_id + 1)) if with_icons: icon = appuifw.Icon(icon_file, icon_id, icon_id + 1) if list_type == 'double': if icon is not None: entries.append((row1, row2, icon)) else: entries.append((row1, row2)) else: if icon is not None: entries.append((row1, icon)) else: entries.append(row1) return entries
def listapps(): global entries,limit lapp=applist.applist() ltask=appswitch.application_list(1) lapp1=[(el[1],el[0]) for el in lapp] lmbm=[] ltask1=[] c=0 # puzzle image for app with no image associated uidpuz=0xa89fd974 puz2=geticon.get(uidpuz,(50,50)) ipuz=Image.from_cfbsbitmap(puz2[0]) mpuz=Image.from_cfbsbitmap(puz2[1]) for el in ltask: luid=[u[1] for u in lapp1 if u[0]==el] if luid==[]: #app with no uid found i2=geticon.get(uidpuz,(50,50)) ltask1.append((el,0)) else: i2=geticon.get(luid[0],(50,50)) ltask1.append((el,luid[0])) try: #app with no image -> puzzle default i=Image.from_cfbsbitmap(i2[0]) imask=Image.from_cfbsbitmap(i2[1]) except: i=ipuz imask=mpuz lmbm.append(i) lmbm.append(imask) c=c+1 multimbm.create(u'd:\\itasks.mbm',lmbm) entries=[] s=0 for task in ltask1: entries.append((task[0],unicode(hex(task[1])),appuifw.Icon(u'd:\\itasks.mbm',s,s+1))) s=s+2
storagepath=u'e:\\' else: mediapath = u'' print sys.argv if len(sys.argv)>2: storagepath=unicode(sys.argv[2]) else: storagepath=u'' #only for documenting it #from graphics import * #filmIt() #set up the icons names = dict(coin=0,opencoin=1,coins=2,detail=3,down=4,left=5,refresh=6, restore=7,right=8,save=9,up=10,zoom=11) icons = dict([(k,appuifw.Icon(mediapath+u'ocicons.mbm',v*2,v*2+1)) for k,v in names.items()]) startup('storage') from oc2 import storage as oc2storage #Try to use a password on the data file. Repeat till its sucessfully loaded password = '' wbpath = storagepath+'wallet.bin' while 0: #don't use the password protected storage, too slow atm. password = appuifw.query(u'password','text') if password == None: sys.exit() startup('data...') storage = oc2storage.CryptedStorage()
def __init__(self): # init app Py7App.__init__(self, self.S_TITLE, self.S_ABOUT) # prepare init choices MBM_AVKON = u"z:\\resource\\apps\\avkon2.mbm" if os.path.isfile(MBM_AVKON): self.initChoices = [ (u"Help", u"read me", appuifw.Icon(MBM_AVKON, 16574, 16575)), (u"Cleanup", u"wizard", appuifw.Icon(MBM_AVKON, 16570, 16571)), (u"Restore", u"from backup", appuifw.Icon(MBM_AVKON, 16592, 16593)) ] else: self.initChoices = [(u"Help", u"read me"), (u"Cleanup", u"wizard"), (u"Restore", u"from backup")] # prepare languages list self.langlist = [] self.langindex2code = {} for lang, code in self.LANGUAGES: index = len(self.langlist) self.langindex2code[index] = code self.langlist.append(unicode("%02d %s" % (code, lang))) self.reres = re.compile("\.[rh](\d{2})\d?") # prepare drives list self.drivelist = [] for item in (u"C:", u"E:"): if os.path.isdir(item + "\\Resource"): self.drivelist.append(unicode(item)) # prepare backup list self.backupdir = "e:\\ResourceBackup" self.backuplist = [self.S_BACKUP, self.S_NOBACKUP] # set menus menuInit = [ (u"Cleanup wizard", self.doCleanup), (u"Restore from backup", self.doRestore), (u"Help", lambda: self.showScreen(self.SCREEN_HELP)), (u"About", self.onAbout), (u"Exit", self.onExit), ] menuBare = [ (u"About", self.onAbout), (u"Exit", self.onExit), ] # set UI elements self.SCREEN_INIT = self.addScreen("list", self.initChoices, None, self.onChoice, menuInit, None) self.SCREEN_HELP = self.addScreen("text", self.S_HELP_INIT, self.SCREEN_INIT, None, menuBare, None) self.SCREEN_CLEANUP = self.addScreen("text", self.S_CLEANUP, self.SCREEN_INIT, None, menuBare, None) self.SCREEN_RESTORE = self.addScreen("text", self.S_RESTORE, self.SCREEN_INIT, None, menuBare, None) self.working = False self.abort = False
# This script creates tabs that let you switch between different applications # listbox app, listbox app and canvas app import appuifw import e32 from graphics import * # define application 1: listobx app # create your icons for the listbox content icon1 = appuifw.Icon(u"z:\\resource\\apps\\avkon2.mbm", 28, 29) icon2 = appuifw.Icon(u"z:\\resource\\apps\\avkon2.mbm", 40, 41) icon3 = appuifw.Icon(u"z:\\resource\\apps\\avkon2.mbm", 30, 31) icon4 = appuifw.Icon(u"z:\\resource\\apps\\avkon2.mbm", 32, 33) icon5 = appuifw.Icon(u"z:\\resource\\apps\\avkon2.mbm", 34, 35) icon6 = appuifw.Icon(u"z:\\resource\\apps\\avkon2.mbm", 36, 37) icon7 = appuifw.Icon(u"z:\\resource\\apps\\avkon2.mbm", 38, 39) # create your content list of your listbox including the icons to be used for each entry entries = [(u"Signal", icon1), (u"Battery", icon2), (u"Sirene", icon3), (u"Waste", icon4), (u"Helicopter", icon5), (u"Train", icon6), (u"Auto", icon7)] # create the listbox callback handler def handler(): #print "done" appuifw.note(unicode("done")) # create an instance of appuifw.Listbox(), include the content list "entries" and the callback function "handler"
def get_icon(self,index,mask=None,name=False): if mask is None:mask=index+1 icon=appuifw.Icon(self.path,index,mask) if name==True: return icon,'' return icon
def std(): date = time.strftime('_%d%m%Y_%H_%M_%S') appuifw.note(ar('you are Recording in ( ')+settings.TYPE+u" ) Format","info") filename =u'E:\\itqpda\\rec'+date+u'.'+settings.TYPE # create your icons for the listbox content icon1 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm", 38, 39) icon2 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm", 04, 05) icon3 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm", 10, 11) icon5 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm", 40, 41) icon6 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm", 10, 11) icon4 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm",12,13) # create your content list of your listbox including the icons to be used for each entry entries = [(ar(' Record'), icon1),(ar(' Play >'), icon5),(ar(' Stop []'), icon3), (ar(' Open Song'), icon4),(ar(' Record Type'), icon2)] def set_type(): tp = appuifw.popup_menu([u'1- amr', u'2- wav'], ar('Type of recorded Sound')) if tp==0: settings.TYPE = u'amr' std() elif tp==1: settings.TYPE = u'wav' std() def rec(): global S S=audio.Sound.open(filename) S.record() appuifw.query(ar('Recording.......\nPress OK to stop recording'), "query") S.stop() def play(): global S try: S=audio.Sound.open(filename) S.play() appuifw.note(ar('Playing'),"info") std() except: appuifw.note(ar('Record first a sound!'),"error") def stop(): global S S.stop() S.close() appuifw.note(ar('Stopped'),"info") std() def open(): appuifw.note(ar('Please Select a Sound ')) filem = fm.manager() spa = filem.AskUser(path=u'e:\\sounds', find='file',ext=[(u'.amr'),(u'.wav'),(u'.mp3')]) if spa: if spa[-1] == '\\': spa=spa[:-1] if spa[-1] == '\\': spa=spa[:-1] filename = spa global S try: S=audio.Sound.open(spa) S.play() appuifw.note(ar('Playing'),"info") except: appuifw.note(ar('Select a Sound!'),"error") # create the listbox callback handler def fun(): index = lb.current() if index ==0:rec() elif index ==1:play() elif index ==2:stop() elif index ==3:open() elif index ==4:set_type() lb = appuifw.Listbox(entries,fun) appuifw.app.body = lb
def show_icons(a_title, a_file, maskfunc=lambda x:x): ''' Create new Listbox with given parameters ''' # a_title: change application title, show list name # a_file: get icons from this file, with full path # id_list: icon id numbers to show, must be list ### REMOVED # maskfunc: define icon mask number algorithm # show_icons(range(0,100,2), lambda x:x+1) # icon number: 0, 2, 4, 6, 8, 10 etc. # mask number: icon number + 1 # http://snippets.dzone.com/posts/show/1482 # You can define more complex mask algoriths # if type(id_list) == int: # id_list = [id_list] # one item # if type(maskfunc) == dict: # allow dict as a func # func = lambda id: maskfunc.get(id,id) # else: # func = maskfunc # S60 3.1 emulator with PyS60 1.4.5 # operatoranimation.mif # splashscreen.mif # S60 1.4.5 S60 5.0 emulator: # apn.mbm # webkit.mbm # Trustboots.mbm # S60 5.0 device with PyS60 1.9.5 # browserbitmaps.mbm # default_app_icon.mbm # enhancedsoftkeybitmap... # GSTvoutStandbyFigure.m... # Defect: browserbitmaps.mbm # N82 PyS60 1.4.5: ok # N82 PyS60 1.9.5: error # Get all icons from given file.mbm entries = [] try: start = 0 count = 0 skip = 1 if a_file.endswith(".mbm"): count = mbm_count(a_file) a_title = unicode(str("%s (%d)" % (a_title, count))) elif a_file.endswith(".mif"): # Todo: how to calculate items inside MIF count = mif_count(a_file) a_title = unicode(str("%s (%d)" % (a_title, count/2))) # PyS60 1.9.5 in S60 3.1 emulator: # AknIcon 5 panic # index greater than the range of TInt16 (that is, above 32767) #start = 16384 if e32.pys60_version_info > (1,9): start = 0 else: start = 16384 count += start skip = 2 for i in range(start, count, skip): # 2-row listbox item to show bigger icon row1 = u"Icon: %s" % i row2 = u"Mask: %s" % maskfunc(i) # Problem: returns "valid" icon even with invalid data icon = appuifw.Icon(a_file, i, maskfunc(i)) entries.append((row1, row2, icon)) finally: # Hox: if you try to "see" more icons that file contains # SymbianError: [Errno -25] KErrEof try: # Make the new listbox visible if len(entries): appuifw.app.body = appuifw.Listbox(entries) appuifw.app.exit_key_handler=menu_init appuifw.app.menu = [ (u"Back", menu_init), (u"About", menu_about), (u"Exit", cb_quit) ] appuifw.app.title = a_title except: # Todo: debug why appuifw.Listbox() fails with some files s = str("Failed to show %d icons (%d)" % (len(entries), (count-start)/skip)) appuifw.note(unicode(s)) menu_init()
# This script creates tabs that let you switch between different applications # listbox app, listbox app and canvas app import appuifw import e32 from graphics import * # define application 1: listobx app # create your icons for the listbox content icon1 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 28, 29) icon2 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 40, 41) icon3 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 30, 31) icon4 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 32, 33) icon5 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 34, 35) icon6 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 36, 37) icon7 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 38, 39) # create your content list of your listbox including the icons to be used for each entry entries = [(u"Signal", icon1), (u"Battery", icon2), (u"Sirene", icon3), (u"Waste", icon4), (u"Helicopter", icon5), (u"Train", icon6), (u"Auto", icon7)] # create the listbox callback handler def handler():