def buildLoadBox(self): # build the load label loadLable = Label(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) loadLable.text = "<b>Processing</b>" loadLable.show() # build the spinning wheel wheel = Progressbar(self, pulse_mode=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) wheel.pulse(True) wheel.show() detailsbtn = Button(self, style="anchor") detailsbtn.text_set("Details") detailsbtn.callback_pressed_add(self.innerWinShow) detailsbtn.show() # build the status label self.statusLabel = Label(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) self.statusLabel.show() # put all the built objects in a vertical box box = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.pack_end(loadLable) box.pack_end(wheel) box.pack_end(self.statusLabel) box.pack_end(detailsbtn) box.show() return box
def update_ui(self, listing_in_progress=False): box = self.header_box box.clear() ui_disabled = True # file listing in progress if listing_in_progress: spin = Progressbar(box, style='wheel', pulse_mode=True) spin.pulse(True) spin.show() box.pack_end(spin) lb = Label(box, text=_('Reading archive, please wait...'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 0.5)) lb.show() box.pack_end(lb) # or header button else: if self.app.file_name is None: txt = _('No archive loaded, click to choose a file') else: ui_disabled = False txt = _('<b>Archive:</b> %s') % \ (os.path.basename(self.app.file_name)) txt = '<align=left>%s</align>' % txt lb = Label(box, ellipsis=True, text=txt) bt = Button(box, content=lb, size_hint_weight=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ) bt.callback_clicked_add(lambda b: \ FileSelectorInwin(self, _('Choose an archive'), self._archive_selected_cb, path=os.getcwd())) box.pack_end(bt) bt.show() # always show the about button sep = Separator(box) box.pack_end(sep) sep.show() ic = SafeIcon(box, 'help-about', size_hint_min=(24, 24)) ic.callback_clicked_add(lambda i: InfoWin(self)) box.pack_end(ic) ic.show() for widget in (self.extract_btn, self.fsb, self.create_folder_chk, self.del_chk): widget.disabled = ui_disabled self.update_fsb_label()
def update_ui(self, listing_in_progress=False): box = self.header_box box.clear() ui_disabled = True # file listing in progress if listing_in_progress: spin = Progressbar(box, style='wheel', pulse_mode=True) spin.pulse(True) spin.show() box.pack_end(spin) lb = Label(box, text=_('Reading archive, please wait...'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 0.5)) lb.show() box.pack_end(lb) # or header button else: if self.app.file_name is None: txt = _('No archive loaded, click to choose a file') else: ui_disabled = False txt = _('<b>Archive:</b> %s') % \ (os.path.basename(self.app.file_name)) txt = '<align=left>%s</align>' % txt lb = Label(box, ellipsis=True, text=txt) bt = Button(box, content=lb, size_hint_weight=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ) bt.callback_clicked_add(lambda b: \ FileSelectorInwin(self, _('Choose an archive'), self._archive_selected_cb, path=os.getcwd())) box.pack_end(bt) bt.show() # always show the about button sep = Separator(box) box.pack_end(sep) sep.show() ic = SafeIcon(box, 'help-about', size_hint_min=(24,24)) ic.callback_clicked_add(lambda i: InfoWin(self)) box.pack_end(ic) ic.show() for widget in (self.extract_btn, self.fsb, self.create_folder_chk, self.del_chk): widget.disabled = ui_disabled self.update_fsb_label()
def __init__(self, parent, text=None, title=None): Popup.__init__(self, parent) self.part_text_set('title,text', title or 'Please wait') box = Box(self, horizontal=True, padding=(6,6)) self.content = box box.show() wheel = Progressbar(self, style='wheel', pulse_mode=True) wheel.pulse(True) box.pack_end(wheel) wheel.show() lb = Label(self, text=text or 'Operation in progress...') box.pack_end(lb) lb.show() self.show()
def item_selected_cb(self, gl, item): name = item.data if item.parent is self.activatable_group: # activate the service, async with a cool popup bus.call_async("org.freedesktop.DBus", "/", "org.freedesktop.DBus", "StartServiceByName", "su", (name, 0), None, None) spinner = Progressbar(self.win, style="wheel", pulse_mode=True) spinner.pulse(True) def stop_waiting_cb(btn): self.waiting_popup.delete() self.waiting_activation = None button = Button(self.win, text="Stop waiting") button.callback_clicked_add(stop_waiting_cb) popup = Popup(self.win, content=spinner) popup.part_text_set('title,text', 'Activating service...') popup.part_content_set('button1', button) popup.show() self.waiting_activation = name self.waiting_popup = popup else: self.win.detail_list.populate(name)
class CommandOutputEntry(Table): def __init__(self, parent, min_size=(0,0)): Table.__init__(self, parent, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self._entry = Entry(self, scrollable=True, editable=False, line_wrap=ELM_WRAP_NONE, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self._wheel = Progressbar(self, style='wheel', pulse_mode=True, size_hint_expand=EXPAND_BOTH) self._rect = Rectangle(self.evas, size_hint_min=min_size, size_hint_expand=EXPAND_BOTH, color=(0,0,0,0)) self.pack(self._entry, 0, 0, 1, 1) self.pack(self._rect, 0, 0, 1, 1) self.pack(self._wheel, 0, 0, 1, 1) self._last_was_carriage = False self._entry.show() self._rect.show() self.show() @property def text(self): return self._entry.text @text.setter def text(self, text): self._entry.text = text def pulse_start(self): self._rect.repeat_events = False self._wheel.pulse(True) self._wheel.show() def pulse_stop(self): self._rect.repeat_events = True self._wheel.pulse(False) self._wheel.hide() def successfull(self): self._entry.entry_append('<success>Operation successfully completed.</success><br>') def failure(self): self._entry.entry_append('<failure>Error! Something goes wrong.</failure><br>') def error_set(self, text): self._entry.text = '<failure>Error:</failure><br>%s' % text def append_raw(self, line, sep=None): if self._last_was_carriage is True: self._entry.cursor_selection_begin() self._entry.cursor_line_end_set() self._entry.cursor_selection_end() self._entry.entry_insert('') if sep == '\n': self._entry.entry_append(line + '<br>') self._entry.cursor_end_set() self._last_was_carriage = False elif sep == '\r': self._entry.entry_append(line) self._last_was_carriage = True else: self._entry.entry_append(line) self._last_was_carriage = False
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, 5) 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, 5, 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, 5, 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, 5, 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, 5, 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) 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 if 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 self.load_notify.content.delete() l = Label( self.load_notify, style="marker", text="Document load error", color=(255, 0, 0, 255)) self.load_notify.content = l l.show() timer = Timer(0.2, worker_check, t) self.parent.callback_delete_request_add(lambda x: timer.delete())
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())