HTML - AddIcon
<head> <link rel="shortcut icon" href="img.ico" /> </head>
11391 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
<head> <link rel="shortcut icon" href="img.ico" /> </head>
>>> from appuifw import * >>> avkon = u'z:\\system\\data\\avkon.mbm' >>> def showicon(id_list, maskfunc=lambda x:x): ... if type(id_list) == int: ... id_list = [id_list] # one item ... entries = [] ... if type(maskfunc) == dict: # allow dict as a func ... func = lambda id: maskfunc.get(id,id) ... else: ... func = maskfunc ... for id in id_list: ... item = u'%s, %s' % (id, func(id)) ... icon = Icon(avkon, id, func(id)) ... entries.append((item, u'', icon)) ... app.body = Listbox(entries, lambda: None) ... >>> showicon(range(503)) # all icons, including mask >>> showicon(range(0,100,2), lambda x:x+1) # first 50 icons, with their mask brother
>>> from appuifw import * >>> from struct import unpack >>> def readL(f, pos=None): # helping function ... if pos is not None: ... f.seek(pos) ... return unpack('L', f.read(4))[0] ... >>> fxmbm = 'E:\\system\\apps\\FExplorer\\FExplorer.mbm' >>> f = open(fxmbm, 'rb') >>> trailer = readL(f, 16) >>> num = readL(f, trailer) # 19 icons >>> offset = [] >>> for i in range(num): ... offset.append(readL(f)) ... >>> offset [20L, 68L, 116L, 474L, 588L, 1038L, 1228L, 1636L, 1864L, 2277L, 2430L, 3735L, 41 69L, 4569L, 4697L, 5197L, 5370L, 5897L, 6062L] >>> start = offset[2] # folder icon >>> f.seek(start) >>> length = readL(f) - readL(f) # length of data section >>> width, height = readL(f), readL(f) # 16 x 13 >>> f.seek(start+0x28) # start of data section >>> data_enc = f.read(length) # got the data >>> def rle24_decode(bytes): ... out = [] ... i = 0 ... while i < len(bytes): ... n = ord(bytes[i]) ... i += 1 ... if n < 0x80: ... out.append( bytes[i:i+3] * (n+1) ) ... i += 3 ... else: ... n = 0x100 - n ... out.append( bytes[i:i+3*n] ) ... i += 3*n ... return ''.join(out) ... >>> data = rel24_decode(data_enc) >>> app.body = canvas = Canvas() >>> for j in range(height): ... for i in range(width): ... p = 3*(j*width+i) ... color = [ord(data[p+k]) for k in (2,1,0)] # It's BGR ... canvas.point((i,j), tuple(color)) ... >>> # folder icon is drawn on screen
# a helping function from struct import unpack def readL(f, pos=None): if pos is not None: f.seek(pos) return unpack('L', f.read(4))[0] # the real counting function def mbm_count(mbm_file): f = open(mbm_file, 'rb') mbm_type = readL(f) if mbm_type == 0x10000041: # mbm on ROM (Z:) return readL(f) elif mbm_type == 0x10000037L: # mbm on file (normal) return readL(f, readL(f, 16)) # read at trailer else: # what type is it? return None
>>> mbm_count('z:\\system\\data\\avkon.mbm') 503L >>> mbm_count('E:\\system\\apps\\FExplorer\\FExplorer.mbm') 19L >>>
from appuifw import * import icon_image, e32 app.body = c = Canvas() # choose a bitmap from plenty inside mbm (multi-bitmap) icon = icon_image('z:\\system\\data\\avkon.mbm', 28) c.blit(icon) e32.ao_sleep(10) # 10 sec to end program
icon1 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 28, 29) icon2 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm ", 40, 41) entries = [(u"Signal", icon1), (u"Battery", icon2)] lb = appuifw.Listbox(entries, lbox_observe)
appuifw.app.body = lb