Commits

gao shuai committed 16ad2ef

all stuffs.

  • Participants
  • Parent commits 8993b59

Comments (0)

Files changed (28)

+# A wrapper around the (optional) built-in class dbm, supporting keys
+# and values of almost any type instead of just string.
+# (Actually, this works only for keys and values that can be read back
+# correctly after being converted to a string.)
+
+
+class Dbm:
+
+    def __init__(self, filename, mode, perm):
+        import e32dbm as dbm
+        self.db = dbm.open(filename, mode, perm)
+
+    def __repr__(self):
+        s = ''
+        for key in self.keys():
+            t = repr(key) + ': ' + repr(self[key])
+            if s: t = ', ' + t
+            s = s + t
+        return '{' + s + '}'
+
+    def __len__(self):
+        return len(self.db)
+
+    def __getitem__(self, key):
+        return eval(self.db[repr(key)])
+
+    def __setitem__(self, key, value):
+        self.db[repr(key)] = repr(value)
+
+    def __delitem__(self, key):
+        del self.db[repr(key)]
+
+    def keys(self):
+        res = []
+        for key in self.db.keys():
+            res.append(eval(key))
+        return res
+
+    def has_key(self, key):
+        return self.db.has_key(repr(key))
+
+
+def test():
+    d = Dbm("e:\\wd_db_tes", 'c', 0600)
+    print d
+    while 1:
+        try:
+            key = input('key: ')
+            if d.has_key(key):
+                value = d[key]
+                print 'currently:', value
+            value = input('value: ')
+            if value is None:
+                del d[key]
+            else:
+                d[key] = value
+        except KeyboardInterrupt:
+            print ''
+            print d
+        except EOFError:
+            print '[eof]'
+            break
+    print d
+
+
+test()
+#Filename:Forguys.py -- a simple game named four number guess
+#42
+import random
+def creatData(numLen=4):
+	import random
+	data=[]
+	ALL_NUM=list('0123456789')
+	tnum=ALL_NUM
+	for i in range(numLen):
+		data.append(random.choice(tnum))
+		tnum=[num for num in tnum if not num in data]
+	return data
+	
+
+class Forguys:
+	'''four number guess'''
+	def __init__(self,numLen=4,maxTimes=8,answer=None,bossKey='b',quitFlag='0'):
+		self.quitFlag=quitFlag
+		self.bossKey=bossKey
+		self.answer=[]
+		self.allAnswers=[]
+		self.ctr=0
+		self.maxTimes=maxTimes-1
+		self.A=[0]*maxTimes
+		self.B=[0]*maxTimes
+		if answer:
+			self.answer=list(answer)
+		else:
+			self.answer=creatData(numLen)
+		
+	def _ask(self,input):
+		'''recive a list'''
+		self.tanswer=input
+		self.allAnswers.append(self.tanswer)
+	def _compare(self):
+		for i in self.tanswer:
+			if i in self.answer and self.tanswer.index(i)==self.answer.index(i):
+				self.A[self.ctr]+=1
+			if i in self.answer and self.tanswer.index(i)!=self.answer.index(i):
+				self.B[self.ctr]+=1
+		
+		return self.A[self.ctr],self.B[self.ctr]
+	def showResult(self):
+		print "".join(self.answer),'<-answer'
+		for i in range(self.ctr):
+			print "".join(self.allAnswers[i]),self.A[i],'A',self.B[i],'B'
+		print 'ctr:',self.ctr+1
+	def run(self,input=None):
+		while 1:
+			try:
+				self._ask(input[self.ctr])
+				if self.ctr==self.maxTimes:
+					self.showResult()
+					# print self.ctr
+					# w=raw_input('Enter to continue')
+					break
+			except:
+				self._ask(list(raw_input('%d TIMES:'%(self.ctr+1))))
+			A,B=self._compare()
+			if A==4 or self.ctr==self.maxTimes or self.tanswer==[self.quitFlag] or self.tanswer==[self.bossKey]:
+				self.showResult()
+				# w=raw_input('Enter to continue')
+				break
+			print A,'A',B,'B'
+			self.ctr+=1
+			
+
+def test(maxTimes=8,numLen=4,answer=None,bossKey="b",quitFlag="0"):
+	testData=[]
+	for i in range(maxTimes):
+		testData.append(creatData(numLen))
+	f=Forguys(numLen,maxTimes,answer,bossKey,quitFlag)
+	f.run(testData)
+
+if __name__=="__main__":
+	numLen=4
+	maxTimes=8
+	bossKey='b'
+	quitFlag='0'
+	answer=None
+	test()
+	while 1:
+		f=Forguys(numLen,maxTimes,answer,bossKey,quitFlag)
+		f.run()
+		if f.tanswer==[f.quitFlag]:
+			break
+	w=raw_input('Enter to quit')

appuifw2_sample.py

+#输入法的操作只对自带的有效
+import appuifw2,e32
+cn=lambda s : s.decode("utf-8")
+print appuifw2.query(cn("吃了吗?"),"query",ok=cn("吃了"),cancel=cn("没有"))
+#ok按键和cancel按键名称
+text=appuifw2.Text(move_callback=None,edit_callback=None,scrollbar=1,skinned=1,word_wrap=0,t9=1,fixed_case=0)
+#move_callback光标移动事件
+#edit_callback编辑事件,文本发生变化调用此功能
+#scrollbar,右边的滚动条
+#skinned,背景使用主题背景
+#word_wrap暂时没弄清有何用
+#t9,英文的自动组词模式开关
+#fixed_case英文输入模式大小写开关1则只能输入大写字母
+appuifw2.app.title=cn("你好")
+text.indicator_text=u"HELLO"
+#设置输入法左边的文字(默认输入法时显示)
+appuifw2.app.body=text
+text.add(text.indicator_text)
+text.insert(0,cn("Hello,how are you?"))
+text.insert(len(text),u"test.")
+#插入字符
+text.set_pos(len(text))
+text.apply(pos=3,length=-2)
+text.set_selection(0,9)
+#(pos,anchor)设置已选字符
+print"(pos,anchor,text):",text.get_selection()
+#返回(pos,anchor,text)(光标,起点/终点,所选字符)
+text.set_word_wrap(1)
+#text.set_limit(10)
+#设置最多输入字符,(默认输入法有效)
+text.set_pos(len(text))
+print "get word info=",text.get_word_info()
+#text.set_allowed_cases(appuifw2.EUpperCase)
+#ELowerCase,ETextCase,EAllCases
+#设置允许的输入法(默认输入法)
+#text.set_case(appuifw2.ELowerCase)
+#设置输入法
+#text.set_input_mode(appuifw2.ENullInputMode)
+#设置输入模式
+#text.set_undo_buffer(pos=0,length=-1)
+#text.move(appuifw2.EFLineDown,select=1)
+#EFNoMoveMent
+#EFLeft,EFRight,EFLineUp,EFLineDown
+#EFPageUp,EFPageDown,EFLineBeg,EFLineEnd
+#text.move_display(appuifw2.EFLineBeg)
+appuifw2.app.screen="normal"
+#text.add(u"\nabcabcabc\nabcabcabc")
+print"coordinate=",text.pos2xy(5)
+print"pos=",text.xy2pos((40,30))
+text.select_all()
+#选取所有
+#text.clear_selection()
+#取消选取
+#text.clear_undo()
+#取消重做
+print "Can undo=",text.can_undo()
+#可否重做
+print "Can cut=",text.can_cut()
+#可否剪切
+print "Can copy=",text.can_copy()
+#可否复制
+print "Can paste=",text.can_paste()
+#可否粘贴
+e32.ao_sleep(1)
+
+text.set_selection(0,5)
+e32.ao_sleep(1)
+
+text.cut()
+e32.ao_sleep(1)
+
+text.undo()
+#重做剪切/粘贴
+e32.ao_sleep(1)
+
+text.set_selection(6,18)
+e32.ao_sleep(1)
+text.copy()
+#复制所选
+e32.ao_sleep(1)
+
+text.set_pos(len(text))
+e32.ao_sleep(0.5)
+print"has_changed=",text.has_changed
+text.paste()
+#text.read_only=1
+#禁止输入,非自带输入法引起崩溃
+text.screen="normal"
+def quit():
+    app_lock.signal()
+text.add(appuifw2.query(u"","text"))
+appuifw2.app.exit_key_handler=quit
+app_lock=e32.Ao_lock()
+app_lock.wait()
 
 Runs on symbian device.
 
-Other detials are under holding.
+Other detials are under holding.
+
+A collection of my pys60 stuffs.

sis/fischerżŘÖĆĆ÷.sis

Binary file added.

sis/gomoku.sis

Binary file added.

sis/snake.sis

Binary file added.

sis/Îĺ×ÓÁŞÖé.sis

Binary file added.

wd_appuifw_text_test.py

+def a(*l):
+    print l
+#a(5,"7")
+li=list("7374976367")
+#a(li)
+#a(*li)
+import appuifw
+import e32
+appuifw.app.body=text=appuifw.Text()
+f=file("e:\\Interrupts.html","r")
+text.add(unicode(f.read()))
+f.close()
+lock=e32.Ao_lock()
+appuifw.app.exit_key_handler=lock.signal
+lock.wait()
+
+blobsize=3
+import appuifw
+from graphics import *
+import e32
+from key_codes import *
+counter=0
+appuifw.app.screen='full'
+img=None
+myfont=u'Sans MT 936_S60'
+
+def handle_event(event):
+    
+    canvas.text((0,12),u'\u5F53\u524D\u70B9\u51FB\u952E\u503C:',0x008000,myfont)
+    return None
+def handle_redraw(rect):
+    if img:
+        canvas.blit(img)
+appuifw.app.body=canvas=appuifw.Canvas(
+    event_callback=handle_event,
+    redraw_callback=handle_redraw)
+img=Image.new(canvas.size)
+
+running=1
+def quit():
+    global running
+    running=0
+appuifw.app.exit_key_handler=quit
+
+location=[img.size[0]/2,img.size[1]/2]
+speed=[0.,0.]
+xs,ys=img.size[0]-blobsize,img.size[1]-blobsize
+gravity=0.03
+acceleration=0.05
+
+import time
+start_time=time.clock()
+n_frames=0
+# To speed things up, we prerender the text.
+labeltext=u'Use arrows to move ball'
+textrect=img.measure_text(labeltext, font='normal')[0]
+text_img=Image.new((textrect[2]-textrect[0],textrect[3]-textrect[1]))
+text_img.clear(0)
+text_img.text((-textrect[0],-textrect[1]),labeltext,fill=0xffffff,font='normal')
+import random
+def drawpoint():
+    global img
+    img.point((random.randint(0,240),random.randint(0,320)),0x00ff00,width=blobsize)
+    handle_redraw(())
+    print "ii"
+    
+appuifw.app.body.bind(42,drawpoint)
+running=1
+while running:
+    img.clear(0)
+    #img.blit(text_img, (0,0))
+    color=random.randint(0,0xffffff)
+    for i in range(120):
+        img.point((random.randint(0,240),random.randint(0,320)),0x00ff00,width=blobsize)
+    handle_redraw(())
+    e32.ao_sleep(0)
+    e32.ao_yield()
+e32.ao_yield()
+from math import *
+def cl(z,m=5.0,alpha=20.0):
+    from math import *
+    alpha=alpha*pi/360.0
+    ha_=1.0
+    c_=0.25
+    res={}
+    res["d"]=m*z
+    res["da"]=(z+2*ha_)*m
+    res["df"]=(z-2*ha_-2*c_)*m
+    res["db"]=res["d"]*cos(alpha)
+    for (key,value) in res.items():
+        print key,":",value
+    return res
+z5=cl(17*3)
+def wc(s=68.0,zs=1440.0,i_=21.0):
+    i=zs/s
+    derta=(i-i_)/i_
+    return i,derta
+print wc()
+def jiwei(k=1.22,H=400):
+    res={}
+    sita=(180*(k-1)/(k+1))*pi/360
+    res["AD"]=(H/2)/sin(sita/2)
+    res["AN"]=(H/2)/tan(sita/2)
+    print res["AD"],sin(sita/2)*1600
+    for (key,value) in res.items():
+        print key,":",value
+    return res
+jiwei()
+def tuicheng(derta_=130):
+    derta_=derta_*pi/360
+    for derta in range(0,140,10):
+        print derta
+        derta=derta*pi/360
+        fai=20*(pi/360)*(1-2*((derta/derta_)**2))
+        print fai*360/pi
+tuicheng()
+def huicheng(derta0=130):
+    derta0=derta0*pi/360
+    for derta in range(180,320,10):
+        print derta
+        derta=derta*pi/360
+        fai=20*(pi/360)*(1-((derta-pi)/derta0))
+        print fai*360/pi
+huicheng()
+def f(*x):
+    return x
+#print map(f,range(2))
+#print reduce(f,range(2))
+import e32dbm
+import random
+import time
+path="e:\\wd_db_test"
+value=str(reduce(f,range(345)))
+def save(key,value):
+    db[key]=value
+db = e32dbm.open(path, 'c')
+stime=time.clock()
+def generateTestData(num=50):
+    for i in range(num):
+        key=str(random.randint(0,1234))
+        #key=str(i)
+        db[key]=value
+        #print i,key
+def displayData(db):
+    KEYS=db.keys()
+    print len(KEYS)
+    for i in KEYS:
+        print i
+displayData(db)
+generateData(65)
+print time.clock()-stime
+# -*- coding: utf-8 -*-
+import sys
+sys.setdefaultencoding("utf8")
+def cn(x):
+    return x.decode("utf8")
+def en(x):
+    return x.encode("utf8")
+filePathName=unicode(en("e:\\cn\\和.txt"),"utf8")
+f=file(filePathName,"w+")
+f.write("和ss")
+f.close()
+f=file(filePathName,"r")
+print f.read()
+f.close()
+#表格界面常用来做软件的设置界面等,非常灵活,请自测代码观察效果。源码来自哇麦网随缘情恋教程
+
+#head
+import appuifw
+def m(x):return x.decode('utf-8')
+
+#定义一些列表,为表格单元格中显示内容做准备
+list0=[m('哇麦'),m('智能论坛'),m('智论坛'),m('能论坛'),m('智能坛')]
+#两项的为选择性型单元格,两者任选其一
+
+list1=(m('随缘情恋'),'text',m('感谢大家的支持!'))
+#首项为提示文字,中项为文本输入框,末项为预设内容
+
+list2=(m('我的Q号'),'number',334246568)
+#首项为提示文字,中项为数字滚动式输入框,末项为预设内容
+
+MAIN_list=[(m('诺机特攻在'),'combo',(list0,0)),list1,list2]
+#这个定义了上面的三个单元格到底怎么排列;首项中的三项分别为提示文字、显示类型、滚动的内容和默认项
+
+#以下使表格显示出来
+start=appuifw.Form(MAIN_list,appuifw.FFormEditModeOnly|appuifw.FFormDoubleSpaced)
+#第一个参数为定义好的表格,第二个参数为类型(appuifw.FFormEditModeOnly表示可编辑状态,appuifw.FFormDoubleSpaced表示每个单元格分两行显示,“|”表示并列,两个效果同时体现出来)
+
+content=start.execute()
+#将定义好的表格界面显示出来
+
+import keycapture,e32,appuifw
+def call(key):
+  if key==63586:
+    appuifw.note(u'this is key','info',1)
+press=keycapture.KeyCapturer(call)
+press.keys=(63586,)
+press.start()
+e32.ao_sleep(10)
+press.stop()

wd_key_mapping.py

+shengMu=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','zh','ch','sh']
+yunMu= ['a','o','e','i','u','ai','ei','ui','ao','ou','iu','ie','ve','er','an','en','in','un','vn','ang','eng','ing','ong']
+from pinyin import pinYin
+import random
+keyDic={"2":"abc","3":"def","4":"ghi","5":"jkl","6":"mno","7":"pqrs","8":"tuv","9":"wxyz"}
+#for (key,value) in keyDic.items():
+    #print key,value
+running=1
+while running:
+    inputKey=list(raw_input(":"))
+    if inputKey==["0"]:
+        running=0
+        break
+    #inputKey=list("943")
+    #print keyDic["2"]
+    tempList=[]
+    word=[]
+    output=[]
+    for key in inputKey:
+        tempList.append(list(keyDic[key]))
+    pinYinNum=1
+    for key in inputKey:
+        pinYinNum*=len(keyDic[key])
+
+    while 1:
+        word=[]
+        for j in range(len(inputKey)):
+            try:
+                w=random.choice(tempList[j])
+                word.append(w)
+                #tempList[j].remove(w)
+            except:
+                pass
+        word="".join(word)
+        if word not in output:
+            output.append(word)
+        word=[]
+        if len(output)==pinYinNum:
+            break
+    print [word for word in output if word  in pinYin]

wd_key_mapping_p.py

+f=file("e:\\python\\1wd\\pinyin.txt","r")
+n=file("e:\\python\\1wd\\pinyin.py","w+")
+n.write(f.read().replace("\n","','"))
+import lark, e32,graphics
+
+
+f=lark.Fill()
+def fl():
+  for i in range(0,702):
+    f.paint(i,702)
+#fl()
+
+lark.scr.link("inf势如破竹o",func=lambda:None,font=lark.available_fonts()[0],align='left')
+lark.scr.text("info还没有",font=lark.available_fonts()[0],align='left')
+
+
+lark.wait()
+lark.abort()
+
+# -*- coding: utf-8 -*-
+second=1
+minute=second*60
+hour=minute*60
+day=hour*24
+year=day*365
+argumentsKeys=["year", "day" , "hour" , "minute","second"]
+arguments={"year": year, "day" :day, "hour" : hour, "minute" : minute,"second":second}
+import time
+
+NOW=int(time.time())
+def getLastTime(time):
+    timeList=[]
+    result="-"
+    t=NOW-time
+    lastNum=0
+    if t<0:
+        return result+"right-now"
+    for key in argumentsKeys:
+        num=t/arguments[key]
+        timeList.append(num)
+        if lastNum!=0:
+            result+=str(num)+key+"s"
+            return result+"--ago"
+        lastNum=num
+        if num:
+            result+=str(num)+key+"s"
+        t=t%arguments[key]
+    return result+"--ago"
+def cn(x):
+    return x.decode("utf8")
+def de(x):
+    return x.decode("utf8")
+def en(x):
+    return x.encode("utf8")
+import e32,graphics
+import appuifw
+import clipboard_CHN
+import e32dbm
+import random
+import time
+path="e:\\wd_db_test"
+
+def clipAndMod(key):
+    global app_lock
+    value=db[key]
+    appuifw.app.screen='normal'
+    appuifw.app.title = unicode(getLastTime(int(key)))
+    appuifw.app.body = text=appuifw.Text()
+    text.add(cn(value))
+    clipboard_CHN.Set(value)
+    app_lock.wait()
+
+def save(key,value):
+    db[key]=value
+db = e32dbm.open(path, 'c')
+stime=time.clock()
+def generateData(value):
+    #key=str(random.randint(0,1234))
+    key=str(int(time.time()))
+    #key=str(i)
+    db[key]=value
+    #print i,key
+    value=de(db[key])
+    popmenu.append(value[:10])
+    
+popmenu=[]
+KEYS=[int(key) for key in db.keys()]
+KEYS.sort()
+def displayData():
+    for key in KEYS:
+        key=str(key)
+        value=de(db[key])
+        popmenu.append(value[:10])
+        #lark.scr.link(value,color=random.randint(0,0xffffff),align='left',font=u'Sans MT 936_S60',func=lambda key=key:clipAndMod(key))
+
+
+def quit():
+    app_lock.signal()
+
+def main():
+    displayData()
+    appuifw.app.screen='normal'
+    appuifw.app.exit_key_handler = quit
+    appuifw.app.title=u"li"
+    appuifw.app.menu=[((cn('输入'),lambda:generateData(value=en(appuifw.query(u'\u8f93\u5165',"text")))))]
+    index = appuifw.popup_menu(popmenu, u"Select:") 
+    clipAndMod(str(KEYS[index]))
+if __name__ == '__main__':
+    app_lock = e32.Ao_lock()
+    main()
+    app_lock.wait()
+# -*- coding: utf-8 -*-
+second=1
+minute=second*60
+hour=minute*60
+day=hour*24
+year=day*365
+argumentsKeys=["year", "day" , "hour" , "minute","second"]
+arguments={"year": year, "day" :day, "hour" : hour, "minute" : minute,"second":second}
+import time
+
+NOW=int(time.time())
+def getLastTime(time):
+    timeList=[]
+    result="-"
+    t=NOW-time
+    lastNum=0
+    if t<0:
+        return result+"right-now"
+    for key in argumentsKeys:
+        num=t/arguments[key]
+        timeList.append(num)
+        if lastNum!=0:
+            result+=str(num)+key+"s"
+            return result+"--ago"
+        lastNum=num
+        if num:
+            result+=str(num)+key+"s"
+        t=t%arguments[key]
+    return result+"--ago"
+def cn(x):
+    return x.decode("utf8")
+def de(x):
+    return x.decode("utf8")
+def en(x):
+    return x.encode("utf8")
+import lark, e32,graphics
+import lark as appuifw
+import clipboard_CHN
+import e32dbm
+import random
+import time
+path="e:\\wd_db_test"
+#value=str(reduce(f,range(345)))
+
+def clipAndMod(key):
+    value=db[key]
+    appuifw.app.screen='normal'
+    appuifw.app.title = unicode(getLastTime(int(key)))
+    appuifw.app.body = text=appuifw.Text()
+    appuifw.app.menu = [(u"Take Photo",back)]
+    text.add(cn(value))
+    clipboard_CHN.Set(value)
+    #lark.query(u'\u8f93\u5165',"text",value)
+    app_lock = e32.Ao_lock()
+    app_lock.wait()
+
+def save(key,value):
+    db[key]=value
+db = e32dbm.open(path, 'c')
+stime=time.clock()
+def generateData(value):
+    #key=str(random.randint(0,1234))
+    key=str(int(time.time()))
+    #key=str(i)
+    db[key]=value
+    #print i,key
+    value=de(db[key])
+    #lark.scr.clear()
+    lark.scr.text(getLastTime(int(key))+"-"*1,color=0xffff00,align='center',font=u'Sans MT 936_S60')
+    lark.scr.link(value,color=0x00ff00,align='left',font=u'Sans MT 936_S60',func=lambda key=key:clipAndMod(key))
+    #displayData()
+def displayData():
+    KEYS=[int(key) for key in db.keys()]
+    KEYS.sort()
+    for key in KEYS:
+        key=str(key)
+        value=de(db[key])
+        lark.scr.text(getLastTime(int(key))+"-"*1,color=0xffff00,align='center',font=u'Sans MT 936_S60')
+        lark.scr.link(value,color=random.randint(0,0xffffff),align='left',font=u'Sans MT 936_S60',func=lambda key=key:clipAndMod(key))
+def back():
+    reload(lark)
+    main()
+def main():
+    #reload(lark)
+    displayData()
+    lark.scr.title="li"
+    menu=lark.Menu((('输入',lambda:generateData(value=en(lark.query(u'\u8f93\u5165',"text")))),))
+    lark.scr.funcs[164]=lambda:lark.show(menu)
+    lark.wait()
+    lark.abort()
+if __name__ == '__main__':
+    main()

wd_mail_box_py.py

+import os
+def cn(x):
+    return x.decode("utf8")
+files=[]
+fileNames=[]
+MAIL_PATH="c:\\Private\\1000484b\\Mail2\\00001001_S\\"
+choices=os.listdir(MAIL_PATH)
+#print choices
+#print dir(os)
+for c in choices:
+    for s in os.listdir(os.path.join(MAIL_PATH,c)):
+        try:
+            fileName=os.listdir(os.path.join(MAIL_PATH,c,s))
+        except OSError:
+            fileName=None
+            pass
+        try:
+            if fileName:
+                fileName=fileName[0]
+                fileNames.append(fileName)
+                files.append(os.path.join(MAIL_PATH,c,s,fileName))
+                print cn(fileName)
+        except IndexError:
+            pass
+            
+import appuifw
+index = appuifw.popup_menu([cn(f) for f in fileNames]
+, u"Select:") 
+
+execfile(files[index])

wd_press_blue_fischer.py

+import struct
+import math
+import appuifw
+from graphics import *
+import e32
+from key_codes import *
+import time
+import random
+
+import lightblue
+
+        
+class BlueFischer:
+    def __init__(self,targetMac='00:11:03:07:05:92',targetPort=1):
+        self.blue=lightblue.socket()
+        self.blue.connect((targetMac,targetPort))
+        self.recv=86
+
+        self.initS60ui()
+    def send(self,data):
+        self.blue.send(chr(0xC1))
+        self.blue.send(chr(data))
+        
+    def initS60ui(self):
+
+        appuifw.app.screen='full'
+        self.img=None
+        self.myfont=u'Sans MT 936_S60'
+        self.running=1
+        self.canvas=appuifw.Canvas(
+            event_callback=self._handle_event,
+            redraw_callback=self._handle_redraw)
+        appuifw.app.body=self.canvas
+        self.img=Image.new(self.canvas.size)
+        #appuifw.app.body.bind(42,lambda:self.quit())
+
+
+    def _handle_redraw(self,rect):
+        if self.img:
+            self.canvas.blit(self.img)
+    def _handle_event(self,event):
+        #print event
+        #self.img.clear(0)
+        self._handle_redraw(())
+        self.canvas.text((0,12),unicode(str(event['keycode'])),0x008000,self.myfont)
+        
+        if event['type'] == appuifw.EEventKey:
+            if event['keycode']==49:
+                self.send(0x01)    #M0ZY
+            elif event['keycode']==42:
+                self.quit()    #M0ZY
+            elif event['keycode']==50:
+                self.send(0x02)    #M0ZY
+            elif event['keycode']==51:
+                self.send(0x04)    #M1ZY
+            elif event['keycode']==52:
+                self.send(0x08)    #M1ZY
+            elif event['keycode']==53:
+                self.send(0x10)    #M2ZY
+            elif event['keycode']==54:
+                self.send(0x20)    #M2ZY
+            elif event['keycode']==55:
+                self.send(0x40)    #M3ZY
+            elif event['keycode']==56:
+                self.send(0x80)    #M3ZY
+        elif event['type'] == appuifw.EEventKeyUp:
+            self.send(0x00)    #ALLSTOP
+            try:
+                self.recv=ord(self.blue.recv(1))
+            except:
+                pass
+        self.canvas.text((0,24),unicode(bin(self.recv)),0x008000,self.myfont)
+        
+        return None
+    def quit(self):
+        self.blue.close()
+        self.running=0
+
+
+    def run(self,cycleTime=1):
+        while self.running:
+            #self.send(0x00)
+            #self.recv=ord(self.blue.recv(1))
+           
+            #self.canvas.text((0,24),unicode(hex(self.recv)),0x008000,self.myfont)
+            #self._handle_redraw(())
+            #time.sleep(cycleTime)
+            #e32.ao_sleep(cycleTime)
+            e32.ao_yield()
+
+
+
+
+
+def bin(x):
+    res=''
+    x=int(x)
+    while x>0:
+        mod=x%2
+        x/=2
+        res+=str(mod)
+    return "".join(reverse(list(res)))
+def reverse(li):
+    for i in range(len(li)):
+        li.insert(i,li[-1])
+        li.pop()
+    return li
+
+
+s=BlueFischer(targetMac='00:11:03:07:05:92',targetPort=1)
+#s=BlueFischer(targetMac='00:11:04:29:02:65',targetPort=1)
+s.run()
+#('00:11:04:29:02:65', u'linvor', 7936)
+import random
+import time
+def randint(begin, end):
+    now = int( time.time() )
+    diff = end - begin
+    try:
+        return int( begin + now % diff )
+    except ZeroDivisionError:
+        return begin
+while 1:
+    print randint(0,240)
+    print random.randint(0,240)
+    time.sleep(1)

wd_random_audio.py

+import audio
+import random
+
+highChar="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+lowChar="abcdefghijklmnopqrstuvwxyz"
+
+def randomAudio(num):
+    tempWord=[]
+    tempLowChar=list(lowChar)
+    for i in range(num):
+        tempChar=random.choice(tempLowChar)
+        tempWord.append(tempChar)
+        tempLowChar.remove(tempChar)
+        #print tempChar,tempLowChar
+    outputWord="".join(tempWord)
+    print outputWord
+    audio.say(outputWord)
+
+def main():
+    for i in range(6):
+        randomAudio(9)
+        
+main()
+import e32
+import appuifw
+
+STARTER=u'z:\\sys\\bin\\Starter.exe'
+CBIN_PATH=u'C:\\sys\\bin\\'
+EBIN_PATH=u'E:\\sys\\bin\\'
+ZBIN_PATH=u'E:\\sys\\bin\\'
+UC=u"UCMobile_0x20020579.exe"
+BROWSER=u"BrowserNG.exe"
+DEDIT=u"DEdit.exe"
+PED=appuifw.app.full_name()
+e32.start_exe(CBIN_PATH+u"UcWeb60Signed.exe"," (http://simple-is-better.com)")
+#e32.start_exe(ZBIN_PATH+BROWSER,"")
+import appuifw
+
+import e32
+
+
+def cn(x):
+    return x.decode("utf-8")
+  
+
+
+appuifw.app.body=m=appuifw.Text()
+
+
+m.add(cn("一起学编程\n打开外部程序"))
+ 
+
+def uc():
+    try:
+        e32.start_exe("UcWeb60.exe","")
+
+    except:
+        e32.start_exe("UcWeb60Signed.exe","http://paojiao.cn")
+
+
+def Browser():
+    e32.start_exe("BrowserNG.exe"," :http://paojiao.cn")
+
+
+appuifw.app.menu = [(cn("UCWEB"),uc),(cn("自带浏览器"),Browser)]
+lock=e32.Ao_lock()
+appuifw.app.exit_key_handler=lock.signal
+lock.wait()
+import keypress
+import e32
+#keypress.simulate_key_mod(49,49,1)
+#e32.ao_sleep(5)
+#keypress.simulate_keyMenu()
+
+import laa
+print dir(laa)
+#运行结果:['__doc__', '__file__', '__name__', 'about', 'execute', 'execute_bg']
+#laa.execute(0x10008d39)
+#启动自带浏览器
+#laa.execute(0x10008d39, u'http://www.google.com')
+#启动自带浏览器并上谷歌,细节:自带浏览器及时之前就已经在后台,他也会不顾一切往谷歌上冲
+#laa.execute_bg(0x10008d39)
+#会完全不知不觉在后台打开自带浏览器,其他跟execute一样
+print laa.about()#作者信息
+
+laa.execute(0x2001f848, u'http://aapig.com')
+#启动UC

wdkcb_ͳ������.py

+import appuifw2,e32
+def cn(x):return x.decode('utf-8')
+nun=0
+def zs(pos,num):
+    global nun
+    nun+=num
+    appuifw2.app.title=cn('当前字数%s'%(nun))
+
+
+appuifw2.app.body=a=appuifw2.Text(text=u'',edit_callback=zs,skinned=True, scrollbar=True)
+
+appuifw2.app.title=cn('测试字数统计')
+
+lock=e32.Ao_lock()
+appuifw2.app.exit_key_handler=lock.signal
+lock.wait()