def menu(): main = appuifw.selection_list(menulist) if main == 0: import filebrowser #will be compiled into .pyc to can be imported if main == 1: settingsmenulist = [u"System", u"Others"] settingsmenu = appuifw.selection_list(settingsmenulist) if settingsmenu == 0: systemlist = u"Jit" systemsettings = appuifw.selection_list(systemlist) if systemsettings == 0: jitlist = [u"jit on", u"jit off"] jitsettings = appuifw.selection_list(jitlist) if jitsettings == 0: global jit jit = True if jitsettings == 1: global jit jit = False if main == 2: appuifw.app.set_exit()
def recharge(): selection = appuifw.selection_list(rechargechoice, search_field=1) if (selection == 0): try: x = appuifw.query(u"Enter coupon amount", "number") y = appuifw.query(u"Enter the recharge serial number", "number") z = encrypt(y) rechargeamt.append(x) rechargeno.append(z) appuifw.note(u"Your recharge coupon stored in encrypted from", "conf") except: appuifw.note(u"Invalid entry", "error") if (selection == 1): if has_items(rechargeamt): b = 0 for i in rechargeamt: a = [u"%d" % (rechargeamt[b])] b = b + 1 selection1 = appuifw.selection_list(a, search_field=1) z = appuifw.query(u"Enter your password to decrypt", 'number') if (z != password): appuifw.note(u"Wrong password") if (z == password): a = '*141#' b = str(rechargeno[selection1]) c = '#' a = a + b + c telephone.dial(a) appuifw.note(u"Recharged successfully with amount %d" % (rechargeamt[selection1])) rechargeamt.remove(rechargeamt[selection1]) rechargeno.remove(rechargeno[selection1])
def run(self): dirs_scanned=0; files_scanned=0; total_dirs=1 appuifw.app.body=self.canvas appuifw.app.exit_key_handler=self.exit while len(self.dir_list): folder_files_scanned=0 dir_index=0; cur_dir=self.dir_list[0] dir_contents=map(lambda x: self.dir_list[0]+'\\'+x, os.listdir(cur_dir)) for i in range(len(dir_contents)): cur_path=dir_contents[i] self.img.clear() self.img.text((5,15),u'Dirs: %d / %d'%(dirs_scanned, total_dirs)) self.img.text((5,28),u'Files in dir: %d / %d'%(folder_files_scanned, len(dir_contents))) self.img.text((5,75),u'Text: %d'%len(self.lists.txt)) self.img.text((5,88),u'Software: %d'%len(self.lists.software)) try: self.img.text((5,45),unicode(self.dir_list[0]), 0, u'LatinPlain12') self.img.text((5,58),unicode(cur_path[cur_path.rfind('\\')+1:]), 0, u'LatinPlain12') except UnicodeError: self.img.text((5,45),appstdio.nice_unicode(self.dir_list[0]), 0, u'LatinPlain12') self.img.text((5,58),appstdio.nice_unicode(cur_path[cur_path.rfind('\\')+1:]), 0, u'LatinPlain12') self.canvas.blit(self.img) if os.path.isdir(cur_path): if dir_index==-1: self.dir_list=[cur_path]+self.dir_list else: self.dir_list+=[cur_path] total_dirs+=1 if self.filters.text(cur_path): self.lists.txt+=[1]#[cur_path] self.img.text((90,75),u'Detected') if self.filters.software(cur_path)==2: self.img.text((90,88),u'MemoryError',0xf00000) elif self.filters.software(cur_path): self.lists.software+=[0]#[cur_path] #try: os.rename(cur_path, r'E:\Restore\Unknown' + cur_path[cur_path.rfind('\\'):]) try: appuifw.Content_handler().open_standalone(cur_path); appuifw.selection_list([]) except OSError: if not appuifw.query(u'OSError','query'): self.exit() self.img.text((90,88),u'Detected') self.canvas.blit(self.img) self.files_log.write(cur_path+'\n') files_scanned+=1 folder_files_scanned+=1 e32.ao_sleep(0) if not self.running: break dirs_scanned+=1 self.dirs_log.write(self.dir_list[0]+'\n') del self.dir_list[self.dir_list.index(cur_dir)] if not self.running: break while self.running: self.img.text((90,135),u'Done',0x008000, u'Alb17') self.canvas.blit(self.img) e32.ao_sleep(0)
def getQueryArgv(self): '''查询成绩时选择学年,学期。''' yearList=jw.viewState.yearListMap self.setWindowTitle(uni("选择学年")) year=appuifw.selection_list(yearList) semesterList=jw.viewState.semesterListMap self.setWindowTitle(uni("选择学期")) semester=appuifw.selection_list(semesterList) return jw.viewState.yearList[year],jw.viewState.semesterList[semester]
def getQueryArgv(self): '''查询成绩时选择学年,学期。''' yearList = jw.viewState.yearListMap self.setWindowTitle(uni("选择学年")) year = appuifw.selection_list(yearList) semesterList = jw.viewState.semesterListMap self.setWindowTitle(uni("选择学期")) semester = appuifw.selection_list(semesterList) return jw.viewState.yearList[year], jw.viewState.semesterList[semester]
def show_list(msgs): msgs.sort() items = [] for msg in msgs: items.append(msg[1][:15]) appuifw.selection_list(items)
def dues(): selection = appuifw.selection_list(dchoices, search_field=1) if (selection == 0): p = appuifw.selection_list(dfriend) if (p >= 0): q = dfriendamt[p] appuifw.note(u"Amount to give him is %d" % (q)) if (selection == 1): p = appuifw.selection_list(wfriend) if (p >= 0): q = wfriendamt[p] appuifw.note(u"Amount to take from him %d" % (q))
def deposit(): selection = appuifw.selection_list(depchoices, search_field=1) global x global z global d c = "check" if (selection == 0 or selection == 1): try: x = appuifw.query(u"Enter the amount to be deposited", 'number') # get the item to be added d = d + x z = z + x if (selection == 1): try: a = appuifw.query(u"Money was taken from", 'text') c = c + a except: appuifw.note(u"Invalid entry", "error") return b = 0 c = 0 flag = 0 for i in dfriend: if (a == i): dfriendamt[b] = dfriendamt[b] + x dfriendamt.append(dfriendamt[b]) flag = 1 b = b + 1 if (flag != 1): dfriend.append(a) dfriendamt.append(x) except: appuifw.note(u"Invalid entry", "error")
def test_list_query(): query_types = ['text', 'code', 'number', 'query', 'float', 'date', 'time'] for query in query_types: appuifw.note(u'Testing query type: ' + unicode(query)) value = appuifw.query(u'Test query', query) if value is not None: if query == 'date': value = time.strftime("%d/%m/%y", time.localtime(value)) elif query == 'time': value = time.strftime("%H:%M", time.gmtime(value)) appuifw.note(u'Value : ' + unicode(value)) else: appuifw.note(u'Query cancelled') single_item_list = [unicode(x) for x in range(10)] double_item_list = [(unicode(x), unicode(x + 1)) for x in range(10)] appuifw.note(u'Testing single item list') value = appuifw.popup_menu(single_item_list, u'Single item list') appuifw.note(u'Selected item : ' + unicode(value)) appuifw.note(u'Testing double item list') value = appuifw.popup_menu(double_item_list, u'Double item list') appuifw.note(u'Selected item : ' + unicode(value)) appuifw.note(u'Testing selection list with search field') value = appuifw.selection_list(single_item_list, search_field=1) appuifw.note(u'Selected item : ' + unicode(value)) for selection_style in ['checkbox', 'checkmark']: appuifw.note(u'Testing multi-selection list, style - ' + unicode(selection_style)) value = appuifw.multi_selection_list(single_item_list, style=selection_style) appuifw.note(u'Selected items : ' + unicode(value))
def win_function(): global bt list = [u'Cambia finestra', u'Chiudi finestra', u'Vai al desktop'] request = appuifw.selection_list(choices=list, search_field=1) if request == 0: bt.sendline("winchange") if request == 1: bt.sendline("winclose") if request == 2: bt.sendline("godesktop")
def add_pic_filesystem(): global limg, limg_path imagedir = u'e:\\images' images = [] full_path = [] files = map(unicode, os.listdir(imagedir)) # save only images for x in files: if os.path.splitext(x)[1] in ('.jpg', '.png', '.gif'): images.append(x) full_path = map(lambda x: imagedir + '\\' + x, images) full_path.sort(key=lambda x: os.path.getmtime(x), reverse = True) index = appuifw.selection_list(map(lambda x: os.path.split(x)[1], full_path)) if index is None: return limg = Image.open(full_path[index]) limg_path = full_path[index] # Resize image if limg.size[0] > 360: if not touch: limg = limg.resize((188, 143), callback = None, keepaspect = 1) else: limg = limg.resize((320, 240), callback = None, keepaspect = 1) # Optimize UI redraw canvas.begin_redraw() handle_redraw() canvas.end_redraw() # Display image in the middle of screen if not touch: canvas.blit(limg, target = (26,26))
def show_options(self, options, required=True): options = [unicode(opt) for opt in options] selected = appuifw.selection_list(options, search_field=1) if selected == None and required: self.error('Host is required') selected = self.show_options(options) return selected
def Restore(): L = [u'UCWEB', u'Opera'] index = appuifw.selection_list(L, 0) if (index == 0): e32.ao_sleep(1) body.clear() body.add(u'\nChecking for UCWEB backup...\n\n') e32.ao_sleep(2) if os.path.isfile('e:\\Others\\MyUCWEB_Backup.zip'): body.add(u'Backup file found. Extracting contents....\n\n') e32.ao_sleep(1) unzip('e:\\MyBrowser_Backup\\', 'e:\\others\\MyUCWEB_Backup.zip') RestoreUCWEB() else: appuifw.note(u'Backup file not found!') if (index == 1): e32.ao_sleep(1) body.clear() body.add(u'\nChecking for Opera backup...\n\n') e32.ao_sleep(2) if os.path.isfile('e:\\Others\\MyOpera_Backup.zip'): body.add(u'Backup file found. Extracting contents....\n\n') e32.ao_sleep(1) unzip('e:\\MyBrowser_Backup\\', 'e:\\others\\MyOpera_Backup.zip') RestoreOpera() else: appuifw.note(u'Backup file not found!')
def startInternet(self): if not self.ip: import sys import socket if sys.platform == 'symbian_s60': self.feedback(u'Prepare internet:please wait...') aps = [ap['name'] for ap in socket.access_points()] aps.sort() time_taken=0 while time_taken < 1: started = time.time() apid = appuifw.selection_list(aps,1) time_taken = time.time() - started if apid == None: return None self.feedback(u'Prepare internet:set access point') socket.set_default_access_point(aps[apid]) else: import socket self.ip = 'some ip' #one time socket, for just finding out our ip s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #anonymity issue here s.connect(('www.google.com',80)) self.ip = s.getsockname()[0] return True
def _select_access_point(self, apid = None): """ Shortcut for socket.select_access_point() TODO: save selected access point to the config TODO: allow user to change access point later """ if apid is not None: self.apid = apid else: access_points = socket.access_points() sort_key = "iapid" decorated = [(dict_[sort_key], dict_) for dict_ in access_points] decorated.sort() access_points = [dict_ for (key, dict_) in decorated] ap_names = [dict_["name"] for dict_ in access_points] ap_ids = [dict_["iapid"] for dict_ in access_points] selected = appuifw.selection_list(ap_names, search_field=1) #print selected, ap_names[selected], ap_ids[selected] if selected is not None: self.apid = ap_ids[selected] if self.apid: self.apo = socket.access_point(self.apid) socket.set_default_access_point(self.apo) self.config["apid"] = self.apid self.save_config() self._update_menu() return self.apid
def query_and_exec(): def is_py(x): ext=os.path.splitext(x)[1].lower() return ext == '.py' or ext == '.pyc' or ext == '.pyo' script_list = [] script_names = [] final_script_list = [] final_script_names = [] for nickname, path in script_dirs: if os.path.exists(path): script_list = map(lambda x: (nickname + x, path + '\\' + x), map(lambda x: unicode(x, 'utf-8'), filter(is_py, os.listdir(path)))) script_names = map(lambda x: unicode(x[0]), script_list) script_names.reverse() script_list.reverse() final_script_list += script_list final_script_names += script_names index = appuifw.selection_list(final_script_names) # We make a fresh, clean namespace every time we run a new script, but # use the old namespace for the interactive console and btconsole sessions. # This allows you to examine the script environment in a console # session after running a script. global script_namespace script_namespace = SelfClearingNamespace() if index >= 0: execfile(final_script_list[index][1].encode('utf-8'), script_namespace.namespace)
def query_and_exec(): def is_py(x): ext = os.path.splitext(x)[1].lower() return ext == '.py' or ext == '.pyc' or ext == '.pyo' script_list = [] script_names = [] final_script_list = [] final_script_names = [] for nickname, path in script_dirs: if os.path.exists(path): script_list = map( lambda x: (nickname + x, path + '\\' + x), map(lambda x: unicode(x, 'utf-8'), filter(is_py, os.listdir(path)))) script_names = map(lambda x: unicode(x[0]), script_list) script_names.reverse() script_list.reverse() final_script_list += script_list final_script_names += script_names index = appuifw.selection_list(final_script_names) # We make a fresh, clean namespace every time we run a new script, but # use the old namespace for the interactive console and btconsole sessions. # This allows you to examine the script environment in a console # session after running a script. global script_namespace script_namespace = SelfClearingNamespace() if index >= 0: execfile(final_script_list[index][1].encode('utf-8'), script_namespace.namespace)
def test_appuifw(): """ Call different api's of appuifw like query, multi_query, selection_list, multi_selection_list, popup_menu and check if these respond to user input appropriately. """ first, last = appuifw.multi_query(u"First Name", u"Last Name") appuifw.note(u"Enter these fields to proceed, " + first, "info") query_func() selected_team = appuifw.selection_list(choices=teams, search_field=1) if selected_team == 1: appuifw.note(u"Nice team to be in", "info") team_members_list = appuifw.multi_selection_list(team_members, style='checkbox', search_field=1) appuifw.note(u"Lets verify it again", "info") team_members_list = appuifw.multi_selection_list(team_members, style='checkmark', search_field=1) appuifw.note(u"Verification Done", "conf") option = appuifw.popup_menu(choice_list, u"How was the experience?") if option == 0: appuifw.note(u"Thank You", "info") else: appuifw.note(u"Loads to improve on!!", "error")
def poll_server(): global voted_already res = json_request({"voter": imei}) votes, winner = res["winner"] if "closed" in res: appuifw.note(u"Winner is %s with %d votes" %\ (winner, votes)) lock.signal() return False elif not voted_already and "title" in res: appuifw.app.title = u"Vote: %s" % res["title"] names = [] for name in res["choices"]: names.append(unicode(name)) idx = appuifw.selection_list(names) if idx == None: lock.signal() return False else: res = json_request({"voter": imei, "choice": names[idx]}) appuifw.note(unicode(res["msg"])) voted_already = True print "Waiting for final results..." else: print "%s has most votes (%d) currently" % (winner, votes) e32.ao_sleep(5, poll_server) return True
def selectLanguage(self, languageList): if not self.sortedLanguageLists.has_key(languageList): self.sortedLanguageLists[languageList] = [] for l in languageLists: self.sortedLanguageLists[languageList].append(l[self.uiLang]) return appuifw.selection_list(search_field=1, choices=self.sortedLanguageLists[languageList])
def memory_lock(self, focused=0): if focused: return screen=appuifw.app.screen appuifw.app.screen='normal' i=appuifw.selection_list([u'Continue',u'Exit']) appuifw.app.screen=screen if i==1: self.exit()
def sys_function(): global bt list = [u'Esegui', u'Esegui utility', u'Riavvia', u'Spegni'] request = appuifw.selection_list(choices=list, search_field=1) if request == 0: start_cmd() if request == 1: start_cmd_standard() if request == 2: bt.sendline("sysrestart") if request == 3: bt.sendline("sysoff")
def fileopen(): appuifw.app.screen = 'normal' w_list = filter(wavfile, os.listdir(path)) index = appuifw.selection_list(map(unicode, w_list)) appuifw.app.screen = 'full' if index > -1: tab.addf(unicode(path + w_list[index])) len(tab.list) == 1 and app_lock.signal()
def selectionListWithSearch(): appuifw.app.body = None myList = [ u'apple', u'banana', u'cherry', u'orange', u'pear', u'strawberry' ] valore = appuifw.selection_list( myList, search_field=1) # possible bug: the searchfield is not displayed
def show_native(): lst = [] for native, foreign in trans: lst.append(native) idx = appuifw.selection_list(choices=lst, search_field=1) if idx != None: foreign = trans[idx][1] fname = PATH + lst[idx] show(fname, foreign)
def selviewsz(): iitems = [(176, 144), (320, 240), (640, 480)] uitems = [u'176x144', u'320x240', u'640x480'] index = appuifw.selection_list(uitems) if index == None: index = 2 return iitems[index]
def show_foreign(): lst = [] for native, foreign in trans: lst.append(foreign) idx = appuifw.selection_list(choices=lst, search_field=1) if idx != None: native = trans[idx][0] fname = PATH + native show(fname, native)
def select_server(self): servers = list(self.servers) index = appuifw.selection_list(servers) if not index is None: server_conf = self.servers[ servers[index] ] self.connect( server_conf['address'], server_conf['port']) self.list_apps() else: self.home()
def f(): ch = appuifw.selection_list([u"Specify sender manually", u"Choose from Contacts"]) if ch == 1: self.engine.select_sender() elif ch == 0: self.engine.edit_sender() if not self.engine.card.has_valid_sender(): raise "sender must be set up to use this application"
def loop(): global duration M = [u"OFF",u"ON"] index= appuifw.selection_list(choices=M, search_field=1) if index==0: duration = 0 if index==1: duration = 6 telephone.dial(str(number)) #make call
def RestoreOpera(): L = [u'Install Drive C', u'Install Drive E'] index = appuifw.selection_list(L, 0) if (index == 0): body.add(u'Restoring. Please wait...\n\n') copytree('e:\\MyBrowser_Backup\\OPERA', 'c:\\system\\data\\opera') else: body.add(u'Restoring. Please wait...\n\n') copytree('e:\\MyBrowser_Backup\\OPERA', 'e:\\system\\data\\opera') RestOfRestore()
def selectDevice(remoteAPI): mobileList = remoteAPI.getMobileList() deviceNames = [] for device in mobileList["devices"]: deviceNames.append(device["name"]) choice = appuifw.selection_list(choices=deviceNames, search_field=1) if choice == None: raise Exception("A device must be selected") else: return mobileList["devices"][choice]["ID"]
def selectDevice(remoteAPI): mobileList = remoteAPI.getMobileList() deviceNames = [] for device in mobileList["devices"]: deviceNames.append(device["name"]) choice = appuifw.selection_list(choices = deviceNames, search_field = 1) if choice == None: raise Exception("A device must be selected") else: return mobileList["devices"][choice]["ID"]
def select_access_point(): """ This opens popup selection where access points are listed and can be selected. Returns selected access point id. """ apid = appuifw.selection_list([i['name'] for i in access_points()]) if apid != None: apid += 1 # do not return zero return apid # may be None
def selection_list(): # define the list of items L = [u'cakewalk', u'com-port', u'computer', u'bluetooth', u'mobile', u'screen', u'camera', u'keys'] # create the selection list: appuifw.selection_list(list , search_field=1 or 0) index = appuifw.selection_list(L , search_field=1) # use the result of the selection to trigger some action (here we just print something) if index == 0: print "cakewalk was selected" else: print "thanks for choosing"
def onSetTarget(self): if not self.targetList: self.targetList = [] for l in TranslateApp.targets: self.targetList.append(l[self.uiLang]) sel = appuifw.selection_list(choices=self.targetList, search_field=1) if sel >= 0: self.target = TranslateApp.targets[sel]["l"] self.saveSettings() self.setTitle()
def select_access_point(): """ This opens popup selection where access points are listed and can be selected. Returns selected access point id. """ apid = appuifw.selection_list([i['name'] for i in access_points()]) if apid != None: apid+=1 # do not return zero return apid # may be None
def OnSelectMap(self): items = [] keys = self.maps.keys() keys.sort() for key in keys: items.append(u"%s" % key) index = ui.selection_list(items) if index != None: ui.note(u"Loading map %s" % keys[index], "info") self.LoadMap(keys[index])
def selcapsz(): iitems = camera.image_sizes() uitems = [] for i in iitems: uitems.append(unicode(i)) index = appuifw.selection_list(uitems) if index == None: index = 0 return iitems[index]
def root(): ui.app.title=u'File Manager' try: drivelist=e32.drive_list() #drivelist=[u'C:', u'D:', u'E:', u'Z:'] index=ui.selection_list(drivelist) opn(drivelist[index]) except: a=ui.query(u'sure to quit?', 'query') if not a: root()
def send_action(): global bt list = [ u'Ok (Invio)', u'Cambia (Tab)', u'Annulla (Esc)', u'Annulla (CTRL + Z)', u'Ripeti (F4)', u'Ripeti (CTRL + Y)', u'Ripeti (CTRL + SHIFT + Z)', u'Salva (SHIFT + F12)', u'Salva (CTRL + S)', u'Salva con nome... (CTRL + SHIFT + S)' ] request = appuifw.selection_list(choices=list, search_field=1) if request >= 0: bt.sendline("action:" + str(request))
def select_scenario(creation=0): try: scenario_list=map(unicode,os.listdir(homecsv)) except: appuifw.note(u'cannot list dir '+str(homecsv),'error') if creation: scenario_list.append(u' + create new?') selected=appuifw.selection_list(scenario_list) if selected==None: return if creation and selected==len(scenario_list)-1: return new_scenario() return scenario_list[selected]
def test_form_flags(): flags = [FFormEditModeOnly, FFormViewModeOnly, FFormAutoLabelEdit, FFormAutoFormEdit, FFormDoubleSpaced] options = [u'EditModeOnly', u'ViewModeOnly', u'AutoLabelEdit', u'AutoFormEdit', u'DoubleSpaced'] item_index = 0 while item_index is not None: item_index = appuifw.selection_list(options) if item_index is not None: f = appuifw.Form(get_simple_form(), flags[item_index]) f.execute()
def run(self): opt = 0 while opt is not None: opt = appuifw.selection_list(self.entries) if opt is not None: if opt == 0 and self.path: self.path.pop() else: self.path.append(self.entries[opt]) if not os.path.isdir(os.path.join(*self.path)): return os.path.join(*self.path) self.update_entries()
def at_list_handler(self): trans_type = self._body.current_item() routes = self._db.get_routes(trans_type) idx = appuifw.selection_list(routes, search_field=1) if idx is not None: self._send_request( SMS.compose_txt(self._db.get_code(trans_type), routes[idx])) msg1 = self._loc(Localizer.WAIT_FOR_A_TICKET) msg2 = self._loc(u'Buy another ticket?') if not appuifw.query(u'%s\n%s' % (msg1, msg2), "query"): appuifw.note(self._loc(u'Bye.')) self.quit()
def money(): selection = appuifw.selection_list(moneychoice, search_field=1) if (selection == 0): deposit() if (selection == 1): withdrawl() if (selection == 2): balance() if (selection == 3): dues() if (selection == 4): ministatement()
def menu(): main = appuifw.selection_list(menulist) if main == 0: print"Not avilible yet" if main == 1: print"Not avilible yet" if main == 2: appuifw.app.set_exit() //I deleted some lines because of it's bug
def favourites(self): def handle_redraw(rect): canvas.blit(img) try: selector = FileSelector("e:\\myPlaces",".jpg") index = appuifw.selection_list(selector.GetKeys()) except: appuifw.note(u"File does not exist", "info") img=Image.open(selector.GetFile(index)) canvas=appuifw.Canvas(redraw_callback=handle_redraw) appuifw.app.body=canvas appuifw.app.menu = [(u"Back",self.back),(u"Exit", self.quit)]
def list_apps(self): if self.apps is None: self.apps = [ unicode(app) for app in self.proxy.list_applications() ] if len(self.apps) == 0: appuifw.note(u"Não existem apps no servidor", u"error") return index = appuifw.selection_list(self.apps) if not index is None: self.run_app( self.apps[index] ) else: self.select_server()
def query_and_exec(): def is_py(x): ext=os.path.splitext(x)[1].lower() return ext == '.py' or ext == '.pyc' or ext == '.pyo' script_list = [] for nickname,path in script_dirs: if os.path.exists(path): script_list += map(lambda x: (nickname+x,path+'\\'+x),\ map(lambda x: unicode(x,'utf-8'), filter(is_py, os.listdir(path)))) index = appuifw.selection_list(map(lambda x: unicode(x[0]), script_list), 1) if index >= 0: execfile(script_list[index][1].encode('utf-8'), globals())
def select_script(): appuifw.app.title = u"Select Script" def is_py(x): return os.path.splitext(x)[1] == '.py' my_script_dir = os.path.join(this_dir,'my') script_list = [] if os.path.exists(my_script_dir): script_list = map(lambda x: os.path.join('my',x),\ filter(is_py, os.listdir(my_script_dir))) script_list += filter(is_py, os.listdir(this_dir)) index = appuifw.selection_list(map(unicode, script_list)) return os.path.join(this_dir, script_list[index])
def opn(obj): ui.app.title=obj try: a=os.listdir(obj) b=[] c=[] for i in a: d=obj+os.sep+i if os.path.isfile(d): c.append(d) else: b.append(d) e=b+c g=[u'<<<']+map(os.path.basename, e) #h=map(os.path.basename, g) #h=[os.path.basename(i) for i in g] f=ui.selection_list(g, 1) if f==0: if obj in [u'C:', u'D:', u'E:', u'Z:']: root() return else: b=os.path.dirname(obj) if b in [u'C:\\', u'D:\\', u'E:\\', u'Z:\\']: opn(b[:2]) return else: opn(b) return elif os.path.isfile(e[f-1]): try: ui.Content_handler().open_standalone(e[f-1]) opn(obj) return except TypeError: ui.note(u'Exception>>\nunable to open file !', 'error') opn(obj) return else: opn(e[f-1]) return except: a=ui.query(u'sure to quit?', 'query') if not a: opn(obj)
def OnFindMap(self): Log("viewer*","Application::OnFindMap()") try: maps = self.FindMapsForPosition(self.pos) items = [] if len(maps) > 0: keys = maps.keys() keys.sort() for key in keys: items.append(u"%s" % key) index = ui.selection_list(items) if index != None: ui.note(u"Loading map %s" % keys[index], "info") self.LoadMap(keys[index]) else: ui.note(u"No maps available", "info") except: DumpExceptionInfo() ui.note(u"Failure while trying to find map", "error")
def change_path(self): print "change_path" cur_dir=self.sgf_file_path index =-1 while index!=0 and index!=None: #print "inwhile: cur_dir=%s" % cur_dir dir=[ name for name in os.listdir(cur_dir) if \ os.path.isdir(os.path.join(cur_dir, name)) ] # insert ".." to go up to root directory dir.insert(0, "..") # done selection dir.insert(0, "done[%s]" % cur_dir) mydir=map(unicode, dir) #print dir[:] index=appuifw.selection_list(mydir) if index: cur_dir=os.path.join(cur_dir, mydir[index]) self.sgf_file_path=cur_dir self.get_sgf_files()