def open_url(self,sender): sv=self.sv d=self.d current_path = editor.get_path() button_title = sender.title #unselect current tab current_tab = self.get_current_tab(current_path) if current_tab: sv[current_tab['name']].background_color = 'white' d[current_tab['name']]['selection']=editor.get_selection() if not d.has_key(button_title): console.hud_alert('missing tab entry for this tab.. ') new_tab=d[button_title] path=new_tab['path'] if not os.path.isfile(path): console.hud_alert('The file for this tab has been moved, renamed, or deleted. the tab will now be removed.', icon = 'error', duration = 3) self.close_button(sender) else: editor.open_file(path) def setsel(): sel=new_tab['selection'] while editor.get_selection()[0] < sel[0]: import time editor.replace_text(sel[0],sel[0],'') editor.replace_text(sel[0]+400,sel[0]+400,'') time.sleep(0.25) editor.set_selection(*sel) ui.delay(setsel,1.0) sender.background_color = 'orange'
def initView(self,filename=None): '''setup the View. if filename is omitted, open current file in editor''' #print os.path.abspath(__file__) #shname=inspect.getfile(inspect.getouterframes(inspect.currentframe())[-1]) p= os.path.dirname(inspect.stack()[-1][1]) s= os.path.join(p,os.path.splitext(__file__)[0]) e=ui.load_view(s) # e=ui.load_view(os.path.splitext(__file__)[0]) e['loadbutton'].action=self.edopen e['savebutton'].action=self.edsave e['selectbutton'].action=self.edselect srcname='editarea.html' w=e['webview1'] w.load_url(os.path.abspath(srcname)) e.present('panel') if filename is not None: f=e['filename'] try: f.text=filename ui.delay(partial( self.edopen,w), 1) except: pass return e
def motion_color(): if not main_view.on_screen : motion.stop_updates() sys.exit(999) color= motion.get_attitude() main_view.background_color = color ui.delay(motion_color, .1)
def scrollview_did_scroll(self, sender): ui.cancel_delays() d = sender.content_offset[0] - 5.0 sender.content_offset = (5, 5) sender.dx = d + sender.dx def hq(): sender.ready = False dx = sender.dx sender.dx = 0 xl = plt.xlim() xl = [x + dx for x in xl] plt.xlim(xl) b = io.BytesIO() plt.savefig(b, format='jpeg', dpi=160) sender.subviews[0].image = ui.Image.from_data(b.getvalue()) sender.ready = True if sender.ready: sender.ready = False dx = sender.dx sender.dx = 0 xl = plt.xlim() xl = [x + dx for x in xl] plt.xlim(xl) b = io.BytesIO() plt.savefig(b, format='jpeg', dpi=16) sender.subviews[0].image = ui.Image.from_data(b.getvalue()) sender.ready = True ui.delay(hq, 0.2)
def _ui_move_auto(board, labels, v, sender): if board.auto_simple(): board.add_tile() if not board.check_move(): gameoverhud() ui.delay(v.close(), 2.5) _ui_setup(board, labels, v)
def motion_color(): if not main_view.on_screen: motion.stop_updates() sys.exit(999) color = motion.get_attitude() main_view.background_color = color ui.delay(motion_color, .1)
def run_script(script_name, full_path=False, delay=None): if not full_path and script_name.startswith('/'): script_name = script_name[1:] if not script_exists(script_name, full_path): error('run_script: script does not exist {}'.format(script_name)) return if full_path: docs_root = os.path.expanduser('~/Documents/') script_name = script_name[len(docs_root):] encoded_name = urllib.parse.quote_plus(script_name, safe='', encoding=None, errors=None) url = 'pythonista3://{}?action=run'.format(encoded_name) if delay: def make_open_url(url): def open(): webbrowser.open(url) return open ui.delay(make_open_url(url), delay) else: webbrowser.open(url)
def advance(): pg = a.progress + random.random() / 10 if pg < 1: a.progress = pg ui.delay(advance, random.random() / 3) else: a.progress = 1
def do_POST(self): form = cgi.FieldStorage(fp=self.rfile, headers=self.headers, environ={'REQUEST_METHOD':'POST', 'CONTENT_TYPE':self.headers['Content-Type']}) self.send_response(200) self.send_header('Content-Type', 'text/html') self.end_headers() field_item = form['file'] uploaded_filename = None dest_filename = None file_data = field_item.file.read() uploaded_filename = field_item.filename dest_filename = self.get_unused_filename(uploaded_filename) with open(dest_filename, 'w') as f: f.write(file_data) editor.reload_files() del file_data if uploaded_filename != dest_filename: message = '%s uploaded (renamed to %s).' % (uploaded_filename, dest_filename) else: message = '%s uploaded.' % (uploaded_filename) '''--------end omz--------''' gcm.message = message gcm.file_name = dest_filename ui.delay(gcm.close, 0)
def loop(): if sender.superview.eval_js('document.forms["form"]["file"].value'): sender.superview.eval_js( 'document.getElementById("submit").click()') else: sound.play_effect('Beep') ui.delay(loop, 2)
def start_action(sender): v1 = sender.superview['view1'] a = ui.ActivityIndicator(name='activity') a.center = v1.bounds.center() a.start_animating() v1.add_subview(a) ui.delay(partial(delay_action, sender), 3)
def __init__(self, queue, server, check_interval=0.2): self.queue = queue self.img = None self.server = server self.check_interval = check_interval self.background_color = 'black' ui.delay(self.check_queue, .1)
def auto_scroll(self): # this busy signal, probably not required. # but will keep it in anyway. its a small price # to pay for extra saftey. if self.busy: ui.cancel_delays() return # thanks @JonB # if the view is not onscreen, we delete ourself # moments later our __del__ is called... if not self.obj.on_screen: print 'off screen' ui.cancel_delays() return self.busy = True # the scrollview sv = self.obj.sv # current offset of the scrollview v_offset = sv.content_offset[1] # calc new_offset, to be + one page new_offset = v_offset + sv.height # wrap around if we reach the bottom if the list if new_offset > sv.content_size[1]: new_offset = 0 sv.content_offset = (0, new_offset ) ui.cancel_delays() ui.delay(self.auto_scroll, self.delay) self.busy = False
def update_timer1(self): if not self.timer1_running: return td = dt.datetime.now() - self.timer1_start_time self.timer1_label.text = str(td.seconds) ui.delay(self.update_timer1, 1)
def run(self, n=None): global X, y, pts, NN if n != None: # that was an initialization call self.n = n self.count = 0 self.liveFeedback(True) # start showing data else: # this a 'current' call self.count += 1 count = self.count kmax = len(self.images) if count < self.n: k = count % kmax y.append(self.y0[k]) img = self.images[k] a = 2 theta = 15 dx = int(random.uniform(-a, a) + 0.5) dy = int(random.uniform(-a, a) + 0.5) th = random.uniform(-theta, theta) zx = random.uniform(0.8, 1.5) v = getVector(img, dx, dy, th, zx) X.append(v) self.liveFeedback() ui.delay(self.run, 0.001) else: self.liveFeedback( False ) # stop showing data (leave here because it uses X as a list) X = np.array(X, dtype=float) # finalize data arrays y = np.array(y, dtype=float) # start training the network NN.trainAll(200) pts = None # self-kill because i am done...
def tableview_did_select(self, tableview, section, row): fname = self.getname() path = os.path.join(table.delegate.curpath, fname) pypath = path if path.endswith(".py") else path + ".py" if os.path.exists(path): return error("Name already taken") if row == 0: # New folder os.mkdir(path) ui.delay(self.pview.close, 0.1) elif row == 1: # New file with open(path, "w"): pass elif row == 2: # File with ui with open(pypath, "w") as fp: fp.write(TEMPLATES["ui"]) uifn = pypath + "ui" with open(uifn, "w") as fp: fp.write(TEMPLATES["pyui"]) elif row == 3: # Scene with layers with open(pypath, "w") as fp: fp.write(TEMPLATES["lscene"]) elif row == 4: # Basic scene with open(pypath, "w") as fp: fp.write(TEMPLATES["bscene"]) table.delegate.update(table, table.delegate.curpath)
def clip_check(): if clipboard.get().startswith('http') and 'instagram' in clipboard.get( ) and '/p/' not in clipboard.get(): ui.delay(get_user_info, 1) return clipboard.get() else: return '剪贴板内容非Ins主页地址!'
def swizzled(self, sel, *args): print('{}:{} called'.format(time.ctime(), method)) print(args) argtypes = parse_types( ObjCInstanceMethod(ObjCInstance(self), method).encoding)[1][2:] newargs = [] for a, ty in zip(args, argtypes): if a is not None and ty is c_void_p: def p(): print(ObjCInstance(a)) ui.delay(p, 1) newargs.append(a) else: def p(): print(a) ui.delay(p, 1) newargs.append(a) returnval = ObjCInstanceMethod(ObjCInstance(self), 'original' + method)(*newargs) print('returnval', returnval) if isinstance(returnval, ObjCInstance): return returnval.ptr else: return returnval
def do_download(self): """ Method to download the zip file. """ url = self.get_url # Create a random name to prevent over-writing an existing archive, just in case. downloadname = str(random.randint(0x000000, 0xFFFFFF)) + "_master.zip" self.add_popup_text('Downloading as {}...'.format(downloadname)) urlretrieve(url, downloadname) self.add_popup_text('Download Complete!') zipped = zipfile.ZipFile(downloadname, 'r') self.add_popup_text('Extracting Zip...') zipped.extractall() zipped.close() self.add_popup_text("Cleaning up...") os.remove(downloadname) self.add_popup_text('Deleted {}'.format(downloadname)) self.add_popup_text('Done!') self.add_popup_text('') self.add_popup_text('Closing Window in 3 seconds...') if self.get_url: self.get_url = None ui.delay(self.closepop, 3)
def GetRandom(sender): # Working global counter counter = counter + 1 x = random.randint(10, 680) y = random.randint(15, 900) B1.frame = (x, y, 95, 50) L1.text = str((counter)) z = random.randint(0, 10) if z == 5: # Ghost appears main_view.add_subview(B3) a = random.randint(10, 680) b = random.randint(15, 900) main_view.add_subview(L5) main_view.background_color = '#d2629c' ui.delay(Ghosttime, 1) # duration before Ghosttime is loaded elif z == 4: # Evil Pig appears main_view.add_subview(B5) q = random.randint(10, 680) w = random.randint(15, 900) main_view.add_subview(L6) main_view.background_color = '#ccd246' ui.delay(PiggyTime, 1)
def button_tapped(self, sender): '''Checks if sender is the winning bit''' if str(sender.name) == self.winTex: self.touch_enabled = False self.count_points(sender.y) sender.image = ui.Image.named( 'emj:Checkmark_3').with_rendering_mode( ui.RENDERING_MODE_ORIGINAL) sound.play_effect('game:Ding_3', 0.2) if self.winTap == False: self.winTap = True def animation(): button.alpha = 0.0 # fade out for button in self.buttons: ui.animate(animation, duration=1.5) for button in self.buttons2: ui.animate(animation, duration=1.5) ui.delay(self.restart, 2) else: sender.image = ui.Image.named( 'emj:Cross_Mark').with_rendering_mode( ui.RENDERING_MODE_ORIGINAL) sound.play_effect('game:Error', 0.2)
def timerNext_tick(): if questionCounter > 0: textBox_answer.text = "" displayQuestion() ui.delay(timerAnswer_tick, 4) else: end()
def open_finder(self, sender): # expand out a view/dialog from sender root = self.find_root() overlay = ui.Button(frame=(0, 0) + tuple(root.frame)[2:], bg_color=(0, 0, 0, 0.25), name='overlay') dialog = ui.View(frame=sender.frame, bg_color='white', name='dialog') self.tbl = ui.TableView() self.tbl.width = dialog.width self.tbl.height = dialog.height self.listsource = ui.ListDataSource(items=[]) self.tbl.data_source = self.listsource self.tbl.delegate = self.listsource self.listsource.action = self.stop_populating self.tbl.flex = 'wh' dialog.add_subview(self.tbl) overlay.add_subview(dialog) overlay.action = self.stop_populating root.add_subview(overlay) self.dialog = dialog def ani(): dialog.x, dialog.y = ui.convert_point( (self.textfield.x, self.textfield.y + self.textfield.height), self, root) dialog.width = self.textfield.width dialog.height = min( 400, root.height - ui.convert_point( (0, dialog.y), self, root)[1]) ui.delay(self.start_populating, 0.16) ui.animate(ani, 0.15)
def advance(): """Advance by a random amount and repeat.""" pg = ppv.progress + random.random() / 20 if pg < 1: ppv.progress = pg ui.delay(advance, random.random() / 2) else: ppv.progress = 1
def tableview_did_select(self, tableview, section, row): # Called when a row was selected. global lastSelectedRow if not self.items[row]['hidden']: self.items[row]['selected'] = not self.items[row]['selected'] viewNodeMap.set_needs_display() lastSelectedRow = row ui.delay(self.delayed_reload,0.05)
def __init__(self): self.create_layout() self.request_counter = 0 self.sync = SyncBackend(self.callback) self.counter = 0 ui.delay(self.increment_counter, 0.05)
def did_stop(self): print 'stopping' #raise Error() self['n'][0].remove_all_actions() [rec.stop() for rec in r] ui.delay(cleanup,0.25) # the scene seems to crash when restarting, unless we raise an error here raise KeyboardInterrupt
def webview_should_start_load(self, webview, url, nav_type): if url.startswith(self.callback_prefix): callback_id = url[len(self.callback_prefix):] callback_func = self.callbacks[callback_id] del self.callbacks[callback_id] ui.delay(callback_func, 0.001) return False return True
def did_stop(self): print 'stopping' #raise Error() self['n'][0].remove_all_actions() [rec.stop() for rec in r] ui.delay(cleanup, 0.25) # the scene seems to crash when restarting, unless we raise an error here raise KeyboardInterrupt
def button(sender): print 'b' def other(): time.sleep(5) # call to some time consuming task print 'c' ui.delay(other, 0.01) #easy way to launch a new thread
def _ui_move_auto(board, labels, v, sender): if board.auto_simple(): board.add_tile() if not board.check_move(): gameoverhud() ui.delay(v.close(), 2.5) _ui_setup(board, labels, v) _setup_buts(board)
def pil_store(self): # save pil image also so it os computed only once img = self.pil_store_params img.pil = Image.open(io.BytesIO(img.image.to_png())) self.stop_act(img) self.set_act(img, 'création miniature') ui.delay(self.build_thumb, 0.1)
def download_now(self, url): """ To Be Completely honest, I forget. """ self.get_url = url self.infopop() self.add_popup_text('Starting...') ui.delay(self.do_download, 2)
def _ui_move(board, labels, v, dir, sender): if board.move(dir): board.add_tile() if not board.check_move(): gameoverhud() ui.delay(v.close(), 2.5) else: _ui_setup(board, labels, v)
def tableview_up(self, sender): tableview = self['kanjis'] if tableview.current > 0: tableview.current = tableview.current - 1 self.table_view_scroll(tableview) ui.delay(self.tableview_say_current, 0.01) #self['kanjis_up'].title = self.get_kanji(-1) # future title to hear self['kanjis_ok'].title = self.select_text + self.get_kanji(0)
def openfile(self,filename): if filename is not None: f=self.view['filename'] try: f.text=filename ui.delay(partial( self.edopen,self.view['open']), 1) except: pass
def crazyCounter(self): self.countRecursions() timeString = time.time() timePlus = str(timeString) + " - " + str(self.recrusionsDone) self.label.text = str(timePlus) ui.delay(self.crazyCounter, 0.0001)
def textfield_should_change(self, textfield, rng, replacement): ui.cancel_delays() self.text=self.text[0:rng[0]]+replacement+self.text[rng[1]:] def replace_with_star() : #textfield.text=textfield.text[0:rng[0]]+'*'*len(replacement)+textfield.text[rng[1]:] textfield.text=len(self.text)*'*' ui.delay(replace_with_star,0.25) return True
def conversion_button_action(self, sender): t = self['hirganas'].text items = [t] try: self.cursor.execute( 'select hiragana, kanji from Hiragana_to_Kanji where hiragana = ?', (t, )) except Exception as e: console.hud_alert( 'be sure that HiraganaToKanji.db file is present', 'error', 3) for li in self.local_kanjis: s = li.split('\t') try: if t not in s[0]: continue items.append(s[1]) break except Exception as e: # lome could be erroneously typed continue w_max = 0 for row in self.cursor: t = row[1] items.append(t) for t in items: w, h = ui.measure_string(t, font=self['kanjis'].data_source.font) w_max = max(w_max, w + 50) sender.hidden = True self['kanjis'].data_source.items = items if len(items) == 1: self.tableview_did_select(self['kanjis'], 0, 0) return # Kanji's exist, display a TableView self['kanjis'].x = (self.width - w_max) / 2 self['kanjis'].width = w_max self['kanjis'].height = min(self.bounds.size[1] - (2 + 32 + 2), len(items) * self['kanjis'].row_height) #self['kanjis'].hidden = False x = self['kanjis'].x + self['kanjis'].width + 10 #self['kanjis_up'].hidden = False self['kanjis_up'].x = x #self['kanjis_ok'].hidden = False self['kanjis_ok'].x = x #self['kanjis_other'].hidden = False # add 1.6 e_b = self['kanjis_ok'].y - self['kanjis_up'].y - self[ 'kanjis_other'].height # add 1.6 self['kanjis_other'].x = self['kanjis'].x - self[ 'kanjis_other'].width - e_b # add 1.6 #self['kanjis_down'].hidden = False self['kanjis_down'].x = x self.hide_buttons(False) self['kanjis'].current = 0 ui.delay(self.tableview_say_current, 0.01) self['kanjis_ok'].title = self.select_text + self.get_kanji(0) self['kanjis_other'].title = self.select_text + self.get_kanji( 0, next_sentence=True) # add 1.9
def do_close(self): def ani(): self.width=10 self.y=self.overlay.height self.height=10 def close(): root=self.find_root(self.root) root.remove_subview(self.overlay) ui.animate(ani,0.25) ui.delay(close,0.25)
def __bRAA(self, sender): ui.cancel_delays() self.__iQ = 5 self.__ipR = ImageP.open('ionicons-ios7-reload-32') self.__bRA.image = ui.Image.named('ionicons-load-d-32') self.__bF2.enabled = False self.__bF3.enabled = False self.__bR1A(object) self.__bR2A(object) self.__bR3A(object) ui.delay(self.__AutoRefresh,3)
def __init__(self): console.hide_output() self._make_self() self._do_warnings() self._make_wv() self._make_bi() self.did_load() self.layout() self.present('popover') ui.delay(self._start, 0.5) self.https.serve_forever()
def do_updates(self): if not self.on_screen: ui.cancel_delays() return # the panel base class has a update() method that just passes. # so its safe to call the method. it needs to be overriden in the # child class for it to do anything. for panel in self.panels: panel.update() ui.delay(self.do_updates, 1)
def touch_began(self, touch): # Called when a touch begins. # set timer for longtap, which gets cancelled in touch ended self.touched=True #self.t = threading.Timer(self.longtouch_delay, self.long_touch) #self.t.start() # ececute do_long_touch after a delay ui.delay(self.do_long_touch, self.longtouch_delay) self.doing_longtouch=False self.set_needs_display() self.lastTouchTime=time.time()
def __init__(self, obj, delay = .1): import console, time # trying for saftey ui.cancel_delays() # no sleeping... console.set_idle_timer_disabled(True) self.obj = obj self.delay = delay self.busy = False # record the start time self.start = time.time() ui.delay(self.auto_scroll, 2)
def log(self, wv, msg, lvl): self["log_view"].text += "%s\n" % msg if lvl == "info": web_logger.info(msg) elif lvl == "debug": web_logger.debug(msg) elif lvl == "error": web_logger.error(msg) elif lvl == "warm": web_logger.warning(msg) ui.delay(self.scroll, 0.0)
def square_tapped(self, sender): sender.image = self.image_o if sender.image == self.image_x else self.image_x winner = self.winner_check() if winner: console.hud_alert('The winner is {}'.format(winner)) ui.delay(self.clear_all_squares, 1) self.computer_pick() winner = self.winner_check() if winner: console.hud_alert('The winner is {}'.format(winner)) ui.delay(self.clear_all_squares, 1)
def address_textfield_action(self,sender): ad_string = sender.text if ad_string.strip() == '': sender.hidden = True return lat,lon = geocodeAddressString(ad_string) if (lat,lon) != (None,None): self.address = ('address',ad_string,lat,lon) sender.text_color = 'black' sender.hidden = True ui.delay(self.add_pin_of_address,0.1) else: sender.text_color = 'red'
def layout(self, sender=None): ui.cancel_delays() if not self.navigation_view: return stations_dict = do_api_get(url, auth) self.navigation_view.name = 'Bike stations as of {} ago'.format( freshness(stations_dict['timeStamp'])) stations = stations_dict['StationStatus'] show_bikes_available = not self.seg_control.selected_index fmt = 'Station {id_} has {occ_} bikes available' self.table_view.data_source.items = [fmt.format(**x) for x in stations if bool(x['occ_']) == show_bikes_available] ui.delay(self.layout, 60) # refresh at least once per minute
def __init__(self): self.name = os.path.splitext(os.path.basename(__file__))[0] self.width, self.height = 320, 160 self._wv = ui.WebView() self._wv.hidden = True self.add_subview(self._wv) self.layout() # subclasses can override self.present('popover') global gCaptureMedia gCaptureMedia = self self.httpsrvr = BaseHTTPServer.HTTPServer(('', 0), TransferRequestHandler) self._wv.load_url('http://localhost:' + str(self.httpsrvr.server_address[1])) ui.delay(self._start, 0.5) self.httpsrvr.serve_forever()
def do_POST(self): environ={'REQUEST_METHOD' : 'POST', 'CONTENT_TYPE' : self.headers['Content-Type']} form = cgi.FieldStorage(fp=self.rfile, headers=self.headers, environ=environ) self.do_headers() form_file = form['file'] dest_filename = self.get_unused_filename(form_file.filename) with open(dest_filename, 'w') as outfile: outfile.write(form_file.file.read()) editor.reload_files() samename = form_file.filename == dest_filename rename_msg = '' if samename else ' (renamed to {})'.format(dest_filename) print('{} uploaded{}.'.format(form_file.filename, rename_msg)) '''--------end omz--------''' ui.delay(gCaptureMedia.close, 0) ui.delay(self.server.shutdown, 0)
def __init__(self): RootView.__init__(self) self.t1=ui.Label(frame=(0,60,400,20)) self.t2=ui.Label(frame=(0,90,400,20)) self.t3=ui.TextView( frame=(0,120,700,200),bg_color=(0.7,0.7,0.7,0.5)) self.t3.text='textview for kb' # the first time the keyboard appears, get kbframe is wrong... # so, show then hide keyboard. self.t3.begin_editing() ui.delay(self.t3.end_editing,0.5) # finally, show kbframe again ui.delay(self.t3.begin_editing,1.0) self.t1.text='touch to begin' [self.add_subview(s) for s in [self.t1,self.t2,self.t3]]
def stop_populating(self,sender): console.hide_activity() root=self.find_root() self._abort=True if not isinstance(sender,ui.Button): #take no action self.textfield.text=sender.items[ sender.selected_row] def act(): if self.textfield.action: self.textfield.action(self.textfield) ui.delay(act,0.1) def ani(): self.dialog.height=0 def cleanup(): root.remove_subview(root['overlay']) ui.delay(cleanup,0.2) ui.animate(ani,0.15)
def __AutoRefresh(self): if self.__iQ == 5: self.__iQ = 1 self.__bF2.enabled = True self.__bF3.enabled = True with io.BytesIO() as bIO: self.__ipR.save(bIO, self.__ipR.format) self.__bRA.image = ui.Image.from_data(bIO.getvalue()) ui.delay(self.__AutoRefresh, 57) else: with io.BytesIO() as bIO: l_ipR = self.__ipR.rotate(-90 * self.__iQ) l_ipR.save(bIO, self.__ipR.format) if self.__iQ == 4: self.__bRAA(object) else: self.__bRA.image = ui.Image.from_data(bIO.getvalue()) self.__iQ += 1 ui.delay(self.__AutoRefresh, 60)
def demo_PathView(): # SETUP p = ui2.get_regular_polygon_path(6, center=(50, 50), radius=50) pv = ui2.PathView(p) pv.x = 150 pv.y = 150 # ANIMATION FUNCTIONS def scaleWidth(): pv.width = 200 def scaleHeight(): pv.height = 200 def scaleBoth(): pv.width = 300 pv.height = 300 def scaleBack(): pv.x, pv.y = 0, 0 pv.width, pv.height = 50, 50 # BASIC USAGE v = ui.View(background_color="white") v.width = v.height = 500 v.add_subview(pv) v.present("sheet", hide_title_bar=True) # PERFORM THE ANIMATIONS ui.animate(scaleWidth, 1) ui.delay(lambda: ui.animate(scaleHeight, 1), 1) ui.delay(lambda: ui.animate(scaleBoth, 1), 2) ui.delay(lambda: ui.animate(scaleBack, 1), 3)
def initView(self,filename=None): '''setup the webview. if filename is omitted, open current file in editor''' #find path of this script, to find abs path of html file self.st=inspect.stack() self.sys=sys p= os.path.dirname([st[1] for st in self.st if st[3]=='initView'][0]) s= os.path.join(p,os.path.splitext(__file__)[0]) srcname='demo/ed_cm.html' w=self.w w.load_url(os.path.join(p,srcname)) hud_alert('wait',duration=1.0) ui.delay(lambda:w.eval_js('resizeEditor()'),0.25) w.delegate = self if filename is not None: f=self.view['filename'] try: f.text=filename ui.delay(partial( self.edopen,w), 0.5) except: pass