def find(): global txt, srh, old try: txt=appuifw2.query(u'Enter search content(case sensitive)','text',txt) except: txt=appuifw2.query(u'Enter search content(case sensitive)','text') if txt!=None: srh=globalui.global_popup_menu([u'Forward',u'Backward'],u'Search Direction') if txt!=None and srh!=None: if srh==0: sp=t.get().find(txt) if sp!=-1: t.set_selection(sp,sp+len(txt)) old=[appuifw2.app.menu_key_text,appuifw2.app.menu] appuifw2.app.menu_key_text=u'Search' appuifw2.app.menu=[(u'Next',next),(u'Previous',prev),(u'Stop',stop)] else: globalui.global_note(u'Text not found','warn') elif srh==1: sp=t.get().rfind(txt) if sp!=-1: t.set_selection(sp,sp+len(txt)) old=[appuifw2.app.menu_key_text,appuifw2.app.menu] appuifw2.app.menu_key_text=u'Search' appuifw2.app.menu=[(u'Next',next),(u'Previous',prev),(u'Stop',stop)] else: globalui.global_note(u'Text not found','warn') else: return None
def lbox(self): ind=self.lb.current() if ind==2: a=ui.selection_list([u'Static', u'Dynamic']) if a==0: static() elif a==1: dynamic() elif ind==0: tnu=self.tnu tcp=self.tcp cgpa=self.cgpa() ui.query(u'TCP :> '+tcp.strip()+'\nTNU :> '+tnu+'\n\nCGPA :> '+cgpa, 'query', None, u'OK', u'Back') else: new=static(int(self.tnu), float(self.tcp)) if not new: return 0 if type(new)!=list: ui.note(u'an error occurred', 'error') return 0 a=open(folder+'%s.gpd'%self.user, 'w') a.write(str(new[1])+'\n') a.write(str(new[0])) a.close() self.update(self.user)
def exit_handle(): s=globalui.global_popup_menu([u'Fake Info \xbb',u'Hide',u'Visit Author\'s FB Page', u'Help \xbb', u'About', u'Exit'],u'Misc',10) if s==0: opt=globalui.global_popup_menu([u'Battery',u'Signal',u'Start Charging',u'Stop Charging'],u'Fake Info',10) if opt==0: try: bar=appuifw2.query(u"No. of bars(0-7)","number",7) indicators.set_battery(bar) if bar==0: globalui.global_note(u'Battery empty.\nRecharge','recharge_battery') if bar==1: globalui.global_note(u'Battery low','battery_low') except: return None elif opt==1: try: bar=appuifw2.query(u"No. of bars(0-7)","number",7) indicators.set_signal(bar) except: return None elif opt==2: globalui.global_note(u'Charging','charging') indicators.start_charging() elif opt==3: indicators.stop_charging() globalui.global_note(u'Unplug charger from power supply to save energy','text') elif s==1: try: appswitch.switch_to_bg(u'Speak') except: return None elif s==2: e32.start_exe('Z:\\sys\\bin\\BrowserNG.exe', (' "4 %s"' % 'http://facebook.com/vishalbiswas')) elif s==3: an = globalui.global_popup_menu([u'General', u'Shortcuts', u'Menu',u'Known Bugs',u'Fake Info'], u'Select Help Conent:') if an==0: msgquery.infopopup(u"Type any text in the textarea and press speak from options to make me say your phrase. You can use any languages which your phone supports. You can download more languages for Text To Speech from Nokia's Official Website.",u'General',msgquery.OKREmpty) if an==1: msgquery.infopopup(u'Middle Selection Key: Speak!\nDial Key: Combine Shortcurts\nRight Soft Key: Miscellaneous tools\nCamera Key: Settings\nVolume Up: Read Text from messages\nVolume Down: Save as txt\nCombination Shortcuts:-\nDial: Screenshot\nClear: Clear all\nUp: Page up\nDown: Page down\nLeft: Start of line\nRight: End of line\nVolume Up:Start of Document\nVolume Down: End of Document\nMiddle Selection: Send text as SMS\n1: Cut\n2: Undo\n3: Text Info\n4: Speak Word\n5: Speak selected\n6: TTS Settings\n7: Reset settings\n8: Find text\n9: Replace text\n0: Exit\n*: Download Languages\n#: Go to line\nCamera: Open file',u'Shortcuts',msgquery.OKREmpty) if an==2: msgquery.infopopup(u'Speak: Speak the text\nEdit: Text related functions like copy, paste, undo, etc\nText: Operations involving the text in the textarea\nGoto: Go to the specific section of the page or navigate through the text\nText Info: Information of the text\nSettings: All the apps\' preferences\nDownload Languages: Download text-to-speech languages from Nokia\'s Official Site',u'Menu',msgquery.OKREmpty) if an==3: msgquery.infopopup(u'1. Applications closes unexpectedly when selecting path of saving or reading files\n2. Changing highlight style resets the font style\n3. The set values in settings are not shown instantly in the settings listbox\n4. Some fonts\' anti-aliasing settings cannot be changed',u'Known Bugs',msgquery.OKREmpty) if an==4: msgquery.infopopup(u'All the changes made by this function are purely fake. They are used to just fool others. I have made it as real as possible.\nBattery: Change the number of bars shown in the battery pane\nSignal: Change the number of bars shown in the signal pane\nStart Charging: Simulates battery charging but in reality doesn\'t charges battery\nStop Charging: Stops the simulation of battery as if battery is full',u'Fake Info',msgquery.OKREmpty) elif s==4: txt=u'Version: '+__version__+'\nMain App: Ensymble\nModded by: vishalbiswas\nE-mail: [email protected]\nUID: '+appuifw2.app.uid().upper()+u'\nPath: '+appuifw2.app.full_name().upper()+u'\nS/W Version: '+sysinfo.sw_version()+u'\nPython Version: '+e32.pys60_version+'\nDetailed Python Version: '+sys.version caps='\nCapabilities Granted: ' if e32.pys60_version_info[0]>=2: for i in e32.get_capabilities(): if i==e32.get_capabilities()[0]: caps+=i else: caps+='+'+i else: caps+=envy.app_capabilities() msgquery.infopopup(txt+caps,u'Speak',msgquery.OKREmpty) elif s==5: quit_ask()
def s_2(): s_3 = appuifw.query(ru('开始位置:'), 'number', s_45.get_selection()[0] - 1) if s_3 == None or s_3 == len(s_45): return s_4 = appuifw.query(ru('结束位置:'), 'number', s_45.get_word_info()[1] - 1) if s_4 == None or s_4 == len(s_45): return if s_3 == s_4: return # if s_4 s_45.set_selection(pos=int(s_3), anchor=int(s_4))
def scrs(): global pth,nae,ext,ppb,qua,com,dela,cur cur=l.current() if cur==0: temp=pth pth=filebrowser.select('Save Screenshots',True) if pth==None: pth=temp else: pth=pth.decode('u8') elif cur==1: temp=nae nae=appuifw2.query(u'Base File Name','text',nae) if nae==None: nae=temp elif cur==2: op=globalui.global_popup_menu([u'JPEG',u'PNG'],u'Extension') if op==0: ext=u'.jpg' elif op==1: ext=u'.png' elif cur==3: opt=globalui.global_popup_menu([u'1',u'8',u'24'],u'BPP') if opt==0: ppb=1 elif opt==1: ppb=8 elif opt==2: ppb=24 elif cur==4: an=appuifw2.query(u'Quality (%)','number',qua) if an!=None: if an>100: qua=100 else: qua=an elif cur==5: opti=globalui.global_popup_menu([u'No Compression',u'Default',u'Fast',u'Best'],u'Image Compression') if opti!=None: if opti==0: com='no' elif opti==1: com='default' elif opti==2: com='fast' elif opti==3: com='best' elif cur==6: sec=appuifw2.query(u'Capture Delay(seconds)','float',dela) if sec!=None: if sec<0: sec=-sec dela=sec selecte(3,'r')
def tex(): global cur cur=l.current() if cur==0: global wrap wrap=not wrap elif cur==1: global ans ans=not ans elif cur==2: global scroll scroll=not scroll elif cur==3: global no temp=no no=appuifw2.query(u'No. of Characters(0:No Limit)','number',no) if no==None: no=temp try: t.set_limit(no) except: return None del temp elif cur==4: global sav sav=not sav selecte(2,'r')
def new_user(self): while True: user=ui.query(u'enter username:'******'text') if not user: return 0 user=user.lower() if os.path.exists(folder+'%s.gpd'%user): ui.note(u'username already exists', 'error') else: break while True: passw=ui.multi_query(u'enter password', u'retype password') if not passw: return 0 if passw[0]!=passw[1]: ui.note(u'password mismatch', 'error') else: break new=open(folder+'%s.gpd'%user, 'w') data=('0', '0') for i in data: new.write(i+'\n') new.close() self.db[user]=passw[0] db=open(folder+'ini.db', 'w') db.write(str(self.db)) db.close() ui.note(u'Success', 'conf') return 1
def dynamic(tnu=0, tcp=0): ui.note(u'lets get started') #tnu=0 tcp=float(tcp) while True: while True: unit=ui.query(u'enter course unit:', 'number') if unit==0: ui.note(u'a value is required') elif not unit: if ui.query(u'Stop Calc', 'query', None, u'Yes', u'No'): return 0 else: break tnu+=unit while True: score=ui.query(u'enter score or grade:', 'text') if not score: if ui.query(u'Stop Calc', 'query', None, u'Yes', u'No'): return 0 elif score in (['%d'%x for x in range(70, 101)]+['A', 'a']): tcp+=5*unit break elif score in (['%d'%x for x in range(60, 70)]+['B', 'b']): tcp+=4*unit break elif score in (['%d'%x for x in range(50, 60)]+['C', 'c']): tcp+=3*unit break elif score in (['%d'%x for x in range(46, 50)]+['D', 'd']): tcp+=2*unit break elif score in (['%d'%x for x in range(40, 46)]+['E', 'e']): tcp+=unit break elif score in (['%d'%x for x in range(40)]+['F', 'f']): break else: ui.note(u'invalid score', 'error') gpa=tcp/tnu if not ui.query(u'ur GPA is: %.3f'%gpa, 'query', None, u'continue', u'stop'): break __comments(gpa) return [tnu, tcp]
def clear_data(self, user): if ui.query(u'sure to clear all records', 'query', None, u'Yes', u'No'): new=open(folder+'%s.gpd'%user, 'w') data=('0', '0') for i in data: new.write(i+'\n') new.close() self.update(user) ui.note(u'cleared', 'conf') return 1
def login(self, username, password, phone=False): loginSuc = False m = md5.new() m.update(password.encode()) pwEnc = m.hexdigest() loginDict = { 'username': username, 'password': pwEnc, 'rememberLogin': '******' } loginUrl = HOST + '/weapi/login/' if phone: loginDict = { 'phone': username, 'password': pwEnc, 'rememberLogin': '******' } loginUrl = loginUrl + '/cellphone' loginCount = 0 while loginSuc == False: if loginCount >= 5: raise Exception, 'Login Failed. Unknown Error' break loginCount += 1 (loginCookie, loginReads) = self.encHttpReq(loginUrl, loginDict) loginReads = json.loads(loginReads) if str(loginReads['code']) == '415': captValid = False captCount = 0 while captValid == False: if captCount >= 5: raise Exception, 'Login Failed. IP Frequent and Many Wrong Captcha' break download(HOST + '/captcha?id=' + loginReads['captchaId'], 'E:\\netease\\data\\captcha.png') inputCapt = appuifw.query( cn('请输入E:\\netease\\data\\captcha.png中的验证码:'), 'text') captReads = self.encHttpReq( HOST + '/weapi/image/captcha/verify/hf', { 'id': loginReads['captchaId'], 'captcha': inputCapt })[1] captReads = json.loads(captReads) if str(captReads['result']) == 'True': captValid = True captCount += 1 elif str(loginReads['code']) == '200': loginSuc = True else: raise Exception, 'Login Failed. Wrong Username or Password?' self.updateCookie(INIT_COOKIE + loginCookie) self.writeCookie() return None
def login(self): user=ui.query(u'enter username:'******'text') if not user: return 1 else: user=user.lower() if user not in self.db.keys(): ui.note(u'username does not exist', 'error') return 0 passw=ui.query(u'enter password:'******'code') if not passw: return 0 else: if passw!=self.db[user]: ui.note(u'incorrect password', 'error') return 0 else: self.passw=passw ui.note(u'Welcome') return self.user_data(user)
def static(): noc=ui.query(u'total no of courses taken:', 'number') if not noc: ui.note(u'no course taken') return 1 iter=0 tnu=0 tcp=float(0) while iter<noc: while True: unit=ui.query(u'enter course unit:', 'number') if unit==0: ui.note(u'a value is required') elif not unit: if ui.query(u'exit GPCalc', 'query', None, u'Yes', u'No'): return 1 else: break tnu+=unit while True: score=ui.query(u'enter score or grade:', 'text') if not score: if ui.query(u'exit GPCalc', 'query', None, u'Yes', u'No'): return 1 elif score in (['%d'%x for x in range(70, 101)]+['A', 'a']): tcp+=5*unit break elif score in (['%d'%x for x in range(60, 70)]+['B', 'b']): tcp+=4*unit break elif score in (['%d'%x for x in range(50, 60)]+['C', 'c']): tcp+=3*unit break elif score in (['%d'%x for x in range(46, 50)]+['D', 'd']): tcp+=2*unit break elif score in (['%d'%x for x in range(40, 46)]+['E', 'e']): tcp+=unit break elif score in (['%d'%x for x in range(40)]+['F', 'f']): break else: ui.note(u'invalid score', 'error') iter+=1 GPA=tcp/tnu if not ui.query(u'ur GPA is: %.3f'%GPA, 'query', None, u'ok', u'comments'): if 5.0>=GPA>=4.5: ui.note(u'FIRST CLASS\nwhao! keep it up', 'info') elif 4.5>GPA>=3.5: ui.note(u'SECOND class, UPPER division\nur best is yet to come') elif 3.5>GPA>=2.5: ui.note(u'SECOND class, LOWER division\nu can do beta') elif 2.5>GPA>=1.5: ui.note(u'THIRD class\nput in more effort') elif 1.5>GPA>=1.0: ui.note(u'This is just a PASS result') else: ui.note(u'u are advised to WITHDRAW')
def gtl(): split=t.get().split(u'\u2029') cul=t.get()[0:t.get_pos()].count(u'\u2029')+1 lin=appuifw2.query(u'Go to line number(1-'+str(len(split))+')','number',cul) if lin!=None: tp=0 if lin==0: lin=1 elif lin>len(split): lin=len(split) for i in range(lin-1): tp+=len(split[i])+1 t.set_pos(tp)
def send_msg(): txt = appuifw2.app.body.get() opt=globalui.global_popup_menu([u'From Contacts',u'Enter Manually'],u'Choose Number') if opt==1: num = appuifw2.query(u'Type the Number', 'float') try: num=int(num) except: return None elif opt==0: nam=appuifw2.query(u'Type the Name','text') con=contacts.ContactsDb() ls=con.find(nam) lst=[] try: for i in ls: lst.append(i.title) lst.sort() se=appuifw2.selection_list(lst,True) num=ls[se][0].value except: return None try: if num==None: return None else: pro = sysinfo.active_profile() if pro == 'offline' : globalui.global_note(u'Phone in Offline profile! Message will be sent later.', 'warn') else: net = sysinfo.signal_bars() if net == 0 : globalui.global_note(u'No signal! Message will be sent later.', 'warn') pass m=messaging.sms_send(num, txt) globalui.global_note(u'Message Submitted succesfully', 'confirm') except: return None
def del_user(): try: if ui.query(u'Confirm Account Delete', 'query', None, u'Confirm', u'Cancel'): os.chmod(folder+'%s.gpd'%user, ~0) os.remove(folder+'%s.gpd'%user) f=open(folder+'ini.db', 'w') del self.db[user] f.write(str(self.db)) f.close() ui.note(u'deleted', 'conf') a.close() return 1 except: ui.note(u'Error\nTry Again', 'error') return 1
def static(): noc=ui.query(u'total no of courses taken:', 'number') if not noc: ui.note(u'no course taken') return 1 iter=0 tnu=0 tcp=float(0) while iter<noc: while True: unit=ui.query(u'enter course unit:', 'number') if unit==0: ui.note(u'a value is required') elif not unit: if ui.query(u'exit GPCalc', 'query', None, u'Yes', u'No'): return 1 else: break tnu+=unit while True: score=ui.query(u'enter score or grade:', 'text') if not score: if ui.query(u'exit GPCalc', 'query', None, u'Yes', u'No'): return 1 elif score in (['%d'%x for x in range(70, 101)]+['A', 'a']): tcp+=5*unit break elif score in (['%d'%x for x in range(60, 70)]+['B', 'b']): tcp+=4*unit break elif score in (['%d'%x for x in range(50, 60)]+['C', 'c']): tcp+=3*unit break elif score in (['%d'%x for x in range(46, 50)]+['D', 'd']): tcp+=2*unit break elif score in (['%d'%x for x in range(40, 46)]+['E', 'e']): tcp+=unit break elif score in (['%d'%x for x in range(40)]+['F', 'f']): break else: ui.note(u'invalid score', 'error') iter+=1 gpa=tcp/tnu if not ui.query(u'ur GPA is: %.3f'%gpa, 'query', None, u'ok', u'comments'): __comments(gpa)
def save(): temp=t.get() fol=filebrowser.select('Save as txt',True) if fol!=None: try: name=appuifw2.query(u"File Name(.txt)","text",u"Document") nam=fol+name+".txt" except: return None try: if os.path.exists(nam): req=globalui.global_query(name+u" already exists. Do you want to overwrite?") if req==1: fil=file(nam,"w") fil.write(temp.encode('u16').replace('\x29\x20','\x0d\x00\x0a\x00')) globalui.global_note(u"Saved to "+nam,'confirm') else: fil=file(nam,"w") fil.write(temp.encode('u16').replace('\x29\x20','\x0d\x00\x0a\x00')) globalui.global_note(u"Saved to "+nam,'confirm') except: globalui.global_note(u"Unable to save","error")
def replace(): global otext, rtext try: otext=appuifw2.query(u'Type the old text(case sensitive)','text',otext) except: otext=appuifw2.query(u'Type the old text(case sensitive)','text') if otext!=None: try: rtext=appuifw2.query(u'Type the replace text(case sensitive)','text',rtext) except: rtext=appuifw2.query(u'Type the replace text(case sensitive)','text') if otext!=None and rtext!=None: try: nor=appuifw2.query(u'Type no. of replaces(optional)','number',nor) except: nor=appuifw2.query(u'Type no. of replaces(optional)','number') if nor!=None and nor!=0: t.set(t.get().replace(otext,rtext,nor)) else: t.set(t.get().replace(otext,rtext))
def exit_key_handler(): if ui.query(u'sure to exit', 'query', None, u'Yes', u'No'): e32.ao_sleep(0.2) # app_lock.signal() ui.app.set_exit()
def fh(): global cur cur=l.current() if cur==0: flist=appuifw2.available_fonts() flist.insert(0,u'Associated Fonts \xbb') fcho=globalui.global_popup_menu(flist,u"Select Font",10) si=t.font[1] fl=t.font[2] if fcho==-1: return None elif fcho==0: opt=globalui.global_popup_menu([u'Normal',u'Annotation',u'Title',u'Legend',u'Symbol',u'Dense'],u'Associated Fonts') if opt==0: t.font='normal' elif opt==1: t.font='annotation' elif opt==2: t.font='title' elif opt==3: t.font='legend' elif opt==4: t.font='symbol' elif opt==5: t.font='dense' else: t.font=(flist[fcho],si,fl) t.apply() elif cur==1: coln=globalui.global_popup_menu([u'Black',u'Bright yellow',u'Dark green',u'Bright red',u'Bright blue',u'Medium gray',u'Blue',u'Pink',u'Orange',u'Violet',u'Type Manually'],u'Select Font Color') if coln==0: t.color=0 elif coln==1: t.color=0xffff00 elif coln==2: t.color=0x004000 elif coln==3: t.color=0xff0000 elif coln==4: t.color=255 elif coln==5: t.color=(128,128,128) elif coln==6: t.color=(0,255/2,255*0.9) elif coln==7: t.color=0xef80c0 elif coln==8: t.color=(255,255/2,0) elif coln==9: t.color=(128,128,192) elif coln==10: f=appuifw2.Form([(u'Red Color Value','number',t.color[0]),(u'Green Color Value','number',t.color[1]),(u'Blue Color Value','number',t.color[2])],appuifw2.FFormEditModeOnly | appuifw2.FFormDoubleSpaced) f.execute() try: t.color=(f[0][2],f[1][2],f[2][2]) except: return None t.apply() elif cur==2: si=appuifw2.query(u'Type the font size(in pixels)','number',t.font[1]) if si!=-1 and si!=None: f=t.font[0] fl=t.font[2] t.font=(f,si,fl) t.apply() elif cur==3: if t.font[2]<=16 and t.font[2]<32: t.font=(t.font[0],t.font[1],32) elif t.font[2]>31 or t.font[2]==None: t.font=(t.font[0],t.font[1],16) t.apply() elif cur==4: i=appuifw2.multi_selection_list([u'Bold',u'Underline',u'Italic',u'Strikethrough'],'checkbox') if i!=(): t.style=0 for c in i: if c==0: if t.style=='': t.style=appuifw2.STYLE_BOLD else: t.style=t.style | appuifw2.STYLE_BOLD elif c==1: if t.style=='': t.style=appuifw2.STYLE_UNDERLINE else: t.style=t.style | appuifw2.STYLE_UNDERLINE elif c==2: if t.style=='': t.style=appuifw2.STYLE_ITALIC else: t.style=t.style | appuifw2.STYLE_ITALIC elif c==3: if t.style=='': t.style=appuifw2.STYLE_STRIKETHROUGH else: t.style=t.style | appuifw2.STYLE_STRIKETHROUGH t.apply() elif cur==5: f=appuifw2.Form([(u'Red Color Value','number',t.highlight_color[0]),(u'Green Color Value','number',t.highlight_color[1]),(u'Blue Color Value','number',t.highlight_color[2])],appuifw2.FFormEditModeOnly | appuifw2.FFormDoubleSpaced) f.execute() try: t.highlight_color=(f[0][2],f[1][2],f[2][2]) except: return None t.apply() elif cur==6: s=globalui.global_popup_menu([u'Standard',u'Rounded',u'Shadow'],u'Highlight Style') if s==0: t.style=t.style | appuifw2.HIGHLIGHT_STANDARD elif s==1: t.style=t.style | appuifw2.HIGHLIGHT_ROUNDED elif s==2: t.style=t.style | appuifw2.HIGHLIGHT_SHADOW t.apply() selecte(1,'r')
def prompt(label, initial=''): return appuifw.query(unicode(label), 'text', unicode(initial))
def hidden(label, initial=''): return appuifw.query(unicode(label), 'code', unicode(initial))
def confirm(label): return appuifw.query(unicode(label), 'query')
appuifw2模块的使用 by明天见 #输入法的操作只对自带的有效 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)设置已选字符
def displayLongText(str1): textArray = [str1[x:x + 30] for x in range(0, len(str1), 30)] for (x, y) in enumerate(textArray): appuifw.query( y + u' (' + str(x + 1) + u'/' + str(len(textArray)) + u')', 'query')