def _tt_text_replace_timed(obj, data, *args, **kargs): timer = data.get("timer") if timer: timer.delete() del data["timer"] obj.text_set("Simple text tooltip, click to start changed timed") return data["timer"] = Timer(1.5, _tt_text_replace_timer_cb, obj, data) obj.text_set("Simple text tooltip, click to stop changed timed")
def begin_test(obj, *args, **kwargs): (pb1, pb2, pb3, pb4, pb5, pb6, pb7, pb8) = args pb2.pulse(True) pb5.pulse(True) pb7.pulse(True) global my_progressbar_run global my_progressbar_timer if not my_progressbar_run: my_progressbar_timer = Timer(0.1, pb_timer_cb, *args) my_progressbar_run = True
def changed_cb(self, widget, *args): func, delay = args[-2:] if delay: if self.save_timer is not None: self.save_timer.delete() self.save_timer = Timer(2.0, self.save_cb, func) else: self.save_cb(func)
def cb_btn3_clicked(bt, ly): ly.edje.part_external_object_get("ext_pbar1").value = 0.0 for part_name in ["ext_pbar2", "ext_pbar5", "ext_pbar7"]: ly.edje.part_external_object_get(part_name).pulse_mode = True ly.edje.part_external_object_get(part_name).pulse(True) for part_name in ["ext_button1", "ext_button2", "ext_button3"]: ly.edje_get().part_external_object_get(part_name).disabled = True Timer(0.1, animate, ly)
def gl_obj_mouse_down(obj, event_info, data): # Launch a timer to start drag animation anim_st = DragAnimSt() anim_st.e = obj.evas anim_st.mdx = event_info.position.canvas.x anim_st.mdy = event_info.position.canvas.y anim_st.gl = data anim_st.tm = Timer(DRAG_TIMEOUT, gl_anim_start, anim_st) data.event_callback_add(EVAS_CALLBACK_MOUSE_UP, gl_obj_mouse_up, anim_st) data.event_callback_add(EVAS_CALLBACK_MOUSE_MOVE, gl_obj_mouse_move, anim_st)
def animate(ly): val = ly.edje.part_external_object_get("ext_pbar1").value val += 0.0123 for part_name in ["ext_pbar1", "ext_pbar3", "ext_pbar4", "ext_pbar6"]: ly.edje.part_external_object_get(part_name).value = val if val < 1: Timer(0.1, animate, ly) else: for part_name in ["ext_pbar2", "ext_pbar5", "ext_pbar7"]: ly.edje.part_external_object_get(part_name).pulse(False) ly.edje.part_external_object_get(part_name).pulse_mode = False for part_name in ["ext_button1", "ext_button2", "ext_button3"]: ly.edje_get().part_external_object_get(part_name).disabled = False return False
def populate_page(self, doc, itr): try: pg_num = next(itr) pg = doc.getPage(pg_num) except StopIteration: if self.doc_pos is not None: self.scr.region_show(*self.doc_pos) def outlines_get(): self.outlines = doc.outlines t1 = time.clock() t = Thread(target=outlines_get) t.daemon = True t.start() def check_outlines(t): if t.is_alive(): return True t2 = time.clock() log.info("Fetching outlines took: %f", t2 - t1) self.outlines_populate(self.outlines) self.load_notify.content.pulse(False) self.load_notify.hide() self.outlines_timer = Timer(0.2, check_outlines, t) return False mbox = pg.mediaBox w, h = mbox[2], mbox[3] box = self.page_box page = Page(box, self.doc_path, pg_num, w, h, self.zoom) page.callback_add("viewport,in", self._viewport_in, self.page_notify) page.callback_add("viewport,out", self._viewport_out, self.page_notify) box.pack_end(page) page.show() self.pages.append((pg.indirectRef.idnum, page)) return True
def my_gl_flush(bt, gl): def my_gl_flush_delay(): cache_all_flush() Timer(1.2, my_gl_flush_delay)
def __init__(self, parent, session): self.parent = parent self.session = session elm_conf = Configuration() scale = elm_conf.scale self.log = logging.getLogger("epour.gui") self.torrentitems = {} win = self.win = StandardWindow("epour", "Epour") win.callback_delete_request_add(lambda x: elm.exit()) win.screen_constrain = True win.size = 480 * scale, 400 * scale mbox = Box(win) mbox.size_hint_weight = 1.0, 1.0 win.resize_object_add(mbox) mbox.show() tb = Toolbar(win) tb.homogeneous = False tb.shrink_mode = ELM_TOOLBAR_SHRINK_NONE tb.select_mode = ELM_OBJECT_SELECT_MODE_NONE tb.size_hint_align = -1.0, 0.0 tb.menu_parent = win item = tb.item_append("document-new", "Add torrent", lambda t, i: self.select_torrent()) def pause_session(it): self.session.pause() it.state_set(it.state_next()) def resume_session(it): session.resume() del it.state item = tb.item_append("media-playback-pause", "Pause Session", lambda tb, it: pause_session(it)) item.state_add("media-playback-start", "Resume Session", lambda tb, it: resume_session(it)) item = tb.item_append("preferences-system", "Preferences") item.menu = True item.menu.item_add(None, "General", "preferences-system", lambda o, i: PreferencesGeneral(self, self.session)) item.menu.item_add(None, "Proxy", "preferences-system", lambda o, i: PreferencesProxy(self, self.session)) item.menu.item_add(None, "Session", "preferences-system", lambda o, i: PreferencesSession(self, self.session)) item = tb.item_append("application-exit", "Exit", lambda tb, it: elm.exit()) mbox.pack_start(tb) tb.show() self.tlist = tlist = Genlist(win) tlist.select_mode = ELM_OBJECT_SELECT_MODE_NONE tlist.mode = ELM_LIST_COMPRESS tlist.callback_activated_add(self.item_activated_cb) tlist.homogeneous = True tlist.size_hint_weight = 1.0, 1.0 tlist.size_hint_align = -1.0, -1.0 tlist.show() mbox.pack_end(tlist) pad = Rectangle(win.evas) pad.size_hint_weight = 1.0, 1.0 p = Panel(win) p.color = 200, 200, 200, 200 p.size_hint_weight = 1.0, 1.0 p.size_hint_align = -1.0, -1.0 p.orient = ELM_PANEL_ORIENT_BOTTOM p.content = SessionStatus(win, session) p.hidden = True p.show() topbox = Box(win) topbox.horizontal = True topbox.size_hint_weight = 1.0, 1.0 win.resize_object_add(topbox) topbox.pack_end(pad) topbox.pack_end(p) topbox.stack_above(mbox) topbox.show() session.alert_manager.callback_add("torrent_added_alert", self.torrent_added_cb) session.alert_manager.callback_add("torrent_removed_alert", self.torrent_removed_cb) for a_name in "torrent_paused_alert", "torrent_resumed_alert": session.alert_manager.callback_add(a_name, self.update_icon) session.alert_manager.callback_add("state_changed_alert", self.state_changed_cb) Timer( 15.0, lambda: session.alert_manager.callback_add( "torrent_finished_alert", self.torrent_finished_cb))
def __init__(self, parent, session): Table.__init__(self, parent) self.session = session s = session.status() self.padding = 5, 5 ses_pause_ic = self.ses_pause_ic = Icon(parent) ses_pause_ic.size_hint_align = -1.0, -1.0 try: if session.is_paused(): ses_pause_ic.standard = "player_pause" else: ses_pause_ic.standard = "player_play" except RuntimeError: self.log.debug("Setting session ic failed") self.pack(ses_pause_ic, 1, 0, 1, 1) ses_pause_ic.show() title_l = Label(parent) title_l.text = "<b>Session</b>" self.pack(title_l, 0, 0, 1, 1) title_l.show() d_ic = Icon(parent) try: d_ic.standard = "down" except RuntimeError: self.log.debug("Setting d_ic failed") d_ic.size_hint_align = -1.0, -1.0 self.pack(d_ic, 0, 2, 1, 1) d_ic.show() d_l = self.d_l = Label(parent) d_l.text = "{}/s".format(intrepr(s.payload_download_rate)) self.pack(d_l, 1, 2, 1, 1) d_l.show() u_ic = Icon(self) try: u_ic.standard = "up" except RuntimeError: self.log.debug("Setting u_ic failed") u_ic.size_hint_align = -1.0, -1.0 self.pack(u_ic, 0, 3, 1, 1) u_ic.show() u_l = self.u_l = Label(parent) u_l.text = "{}/s".format(intrepr(s.payload_upload_rate)) self.pack(u_l, 1, 3, 1, 1) u_l.show() peer_t = Label(parent) peer_t.text = "Peers" self.pack(peer_t, 0, 4, 1, 1) peer_t.show() peer_l = self.peer_l = Label(parent) peer_l.text = str(s.num_peers) self.pack(peer_l, 1, 4, 1, 1) peer_l.show() self.show() self.update_timer = Timer(1.0, self.update)
def run(self): self.win.show() self.timer = Timer(1.0, self.update) elm.run() self.quit()
def __init__(self, parent, path, pos=None, zoom=1.0): self.doc_path = path self._zoom = zoom self.doc_pos = pos self.pages = [] self.doc = None self.doc_title = os.path.splitext(os.path.basename(path))[0] self.visible_pages = [] super(Document, self).__init__(parent, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) scr = self.scr = Scroller(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) scr.callback_scroll_add(self._scrolled) self.pack(scr, 0, 0, 4, 1) scr.show() box = self.page_box = Box(scr, size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, 0.0)) scr.content = box self.on_resize_add(self._resized) btn = Button(self, text="Toggle outlines", size_hint_align=ALIGN_LEFT) btn.callback_clicked_add(lambda x: self.ol_p.toggle()) self.pack(btn, 0, 1, 1, 1) btn.show() spn = self.spn = Spinner(self, round=1.0, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) spn.special_value_add(1, "First") spn.editable = True self.pack(spn, 1, 1, 1, 1) spn.show() btn = Button(self, text="show page", size_hint_weight=EXPAND_HORIZ, size_hint_align=ALIGN_LEFT) btn.callback_clicked_add(self._show_page_cb, spn) self.pack(btn, 2, 1, 1, 1) btn.show() menu = Menu(self.top_widget) menu.item_add(None, "Zoom In", "zoom-in", lambda x, y: self.zoom_in()) menu.item_add(None, "Zoom Out", "zoom-out", lambda x, y: self.zoom_out()) menu.item_add(None, "Zoom 1:1", "zoom-original", lambda x, y: self.zoom_orig()) menu.item_add(None, "Zoom Fit", "zoom-fit-best", lambda x, y: self.zoom_fit()) def z_clicked(btn): x, y = btn.evas.pointer_canvas_xy_get() menu.move(x, y) menu.show() zlbl = self.zlbl = Button(self, text="%1.0f %%" % (self.zoom * 100.0), size_hint_weight=EXPAND_HORIZ, size_hint_align=ALIGN_RIGHT) zlbl.callback_clicked_add(z_clicked) self.pack(zlbl, 3, 1, 1, 1) zlbl.show() n = self.page_notify = Notify(scr, align=(0.02, 0.02)) b = Box(n, horizontal=True, padding=(6, 0)) n.content = b n = self.load_notify = Notify(scr, align=(0.98, 0.98)) pb = Progressbar(n, pulse_mode=True, style="wheel") n.content = pb pb.pulse(True) n.show() p = self.ol_p = Panel( self, orient=ELM_PANEL_ORIENT_LEFT, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, ) #scrollable=True, scrollable_content_size=0.35) p.hidden = True scr.on_move_add(lambda x: p.move(*x.pos)) scr.on_resize_add(lambda x: p.resize(x.size[0] * 0.35, x.size[1])) ol_gl = self.ol_gl = Genlist(p, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, mode=ELM_LIST_COMPRESS, homogeneous=True, select_mode=ELM_OBJECT_SELECT_MODE_ALWAYS) p.content = ol_gl ol_gl.callback_contract_request_add(self._gl_contract_req) ol_gl.callback_contracted_add(self._gl_contracted) ol_gl.callback_expand_request_add(self._gl_expand_req) ol_gl.callback_expanded_add(self._gl_expanded) ol_gl.show() p.show() self.show() def read_worker(): t1 = self.t1 = time.clock() try: self.doc = PyPDF2.PdfFileReader(path) self.page_count = self.doc.getNumPages() except Exception as e: log.exception("Document could not be opened because: %r", e) self.doc = None self.display_error(e) return t2 = time.clock() log.info("Reading the doc took: %f", t2 - t1) t = Thread(target=read_worker) t.daemon = True t.start() def worker_check(t): if t.is_alive(): return True elif self.doc and self.page_count: spn.special_value_add(self.page_count, "Last") spn.min_max = (1, self.page_count) if self.doc.isEncrypted: PasswordPrompt(self) return False self.metadata_read() self.populate_pages() return False timer = Timer(0.2, worker_check, t) self.parent.callback_delete_request_add(lambda x: timer.delete())
def __init__(self, session): self.session = session self.timer = Timer(self.update_interval, self.update)