Example #1
0
    def build_prog_popup(self):
        pp = Popup(self)
        pp.part_text_set('title,text', _('Extracting files, please wait...'))
        pp.show()

        vbox = Box(self)
        pp.part_content_set('default', vbox)
        vbox.show()

        lb = Label(self,
                   ellipsis=True,
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_HORIZ)
        vbox.pack_end(lb)
        lb.show()

        pb = Progressbar(pp,
                         size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ)
        vbox.pack_end(pb)
        pb.show()

        bt = Button(pp, text=_('Cancel'))
        bt.callback_clicked_add(lambda b: self.app.abort_operation())
        pp.part_content_set('button1', bt)

        self.prog_pbar = pb
        self.prog_label = lb
        self.prog_popup = pp
Example #2
0
File: gui.py Project: lonid/epack
    def build_prog_popup(self):
        pp = Popup(self)
        pp.part_text_set('title,text', _('Extracting files, please wait...'))
        pp.show()

        vbox = Box(self)
        pp.part_content_set('default', vbox)
        vbox.show()

        lb = Label(self, ellipsis=True, size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_HORIZ)
        vbox.pack_end(lb)
        lb.show()

        pb = Progressbar(pp, size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ)
        vbox.pack_end(pb)
        pb.show()

        bt = Button(pp, text=_('Cancel'))
        bt.callback_clicked_add(lambda b: self.app.abort_operation())
        pp.part_content_set('button1', bt)

        self.prog_pbar = pb
        self.prog_label = lb
        self.prog_popup = pp
Example #3
0
    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
Example #4
0
File: gui.py Project: wfx/epack
    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()
Example #5
0
def image_clicked(obj):
    win = StandardWindow("image", "Image test", autodel=True, size=(320, 480))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    win.resize_object_add(vbox)
    vbox.show()

    im = Image(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
        file=os.path.join(img_path, "logo.png"))
    vbox.pack_end(im)
    im.show()

    sep = Separator(win, horizontal=True)
    vbox.pack_end(sep)
    sep.show()

    hbox = Box(win, layout=ELM_BOX_LAYOUT_FLOW_HORIZONTAL,
        size_hint_align=FILL_BOTH)
    vbox.pack_end(hbox)
    hbox.show()

    for rot in orients:
        b = Button(win, text=rot[0])
        hbox.pack_end(b)
        b.callback_clicked_add(lambda b, y=rot[1]: im.orient_set(y))
        b.show()

    sep = Separator(win, horizontal=True)
    vbox.pack_end(sep)
    sep.show()

    hbox = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
    vbox.pack_end(hbox)
    hbox.show()

    b = Button(win, text="Set remote URL")
    hbox.pack_end(b)
    b.callback_clicked_add(lambda b: im.file_set(remote_url))
    b.show()

    pb = Progressbar(win, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    hbox.pack_end(pb)
    pb.show()

    im.callback_download_start_add(_cb_im_download_start, pb)
    im.callback_download_done_add(_cb_im_download_done)
    im.callback_download_progress_add(_cb_im_download_progress, pb)
    im.callback_download_error_add(_cb_im_download_error, pb)

    win.show()
Example #6
0
    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)
Example #8
0
    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()
Example #9
0
    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()
Example #10
0
    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
Example #11
0
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
Example #12
0
    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())
Example #13
0
    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 progressbar_clicked(obj):
    win = StandardWindow("progressbar", "Progressbar test")
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bx)
    bx.show()

    pb1 = Progressbar(win, span_size=300, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_HORIZ)
    bx.pack_end(pb1)
    pb1.show()

    pb2 = Progressbar(win, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_HORIZ, text="Infinite bounce", pulse_mode=True)
    bx.pack_end(pb2)
    pb2.show()

    ic1 = Icon(win, file=os.path.join(img_path, "logo_small.png"),
        size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))

    pb3 = Progressbar(win, text="Inverted", content=ic1, inverted=True,
        unit_format="%1.1f units", size_hint_align=FILL_HORIZ,
        size_hint_weight=EXPAND_BOTH)
    bx.pack_end(pb3)
    ic1.show()
    pb3.show()

    pb8 = Progressbar(win, style="double", text="Style: double",
        size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH)
    bx.pack_end(pb8)
    pb8.show()

    hbx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH)
    bx.pack_end(hbx)
    hbx.show()

    pb4 = Progressbar(win, horizontal=False, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH, span_size=60, text="Vertical")
    hbx.pack_end(pb4)
    pb4.show()

    pb5 = Progressbar(win, horizontal=False, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_HORIZ, span_size=120, pulse_mode=True,
        unit_format=None, text="Infinite bounce")
    hbx.pack_end(pb5)
    pb5.show()

    ic2 = Icon(win, file=os.path.join(img_path, "logo_small.png"),
        size_hint_aspect=(EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1))

    pb6 = Progressbar(win, horizontal=False, text="Inverted", content=ic2,
        inverted=True, unit_format="%1.2f%%", span_size=200,
        size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ)
    hbx.pack_end(pb6)
    ic2.show()
    pb6.show()

    pb7 = Progressbar(win, style="wheel", text="Style: wheel", pulse_mode=True,
        size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ)
    bx.pack_end(pb7)
    pb7.show()

    bt_bx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    bx.pack_end(bt_bx)
    bt_bx.show()

    pbt = (pb1, pb2, pb3, pb4, pb5, pb6, pb7, pb8)

    bt = Button(win, text="Start")
    bt.callback_clicked_add(begin_test, *pbt)
    bt_bx.pack_end(bt)
    bt.show()

    bt = Button(win, text="Stop")
    bt.callback_clicked_add(end_test, *pbt)
    bt_bx.pack_end(bt)
    bt.show()

    win.callback_delete_request_add(clean_up, *pbt)
    win.show()
Example #15
0
def progressbar_clicked(obj):
    win = StandardWindow("progressbar", "Progressbar test")
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bx)
    bx.show()

    pb1 = Progressbar(win,
                      span_size=300,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_HORIZ)
    bx.pack_end(pb1)
    pb1.show()

    pb2 = Progressbar(win,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_HORIZ,
                      text="Infinite bounce",
                      pulse_mode=True)
    bx.pack_end(pb2)
    pb2.show()

    ic1 = Icon(win,
               file=os.path.join(img_path, "logo_small.png"),
               size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))

    pb3 = Progressbar(win,
                      text="Inverted",
                      content=ic1,
                      inverted=True,
                      unit_format="%1.1f units",
                      size_hint_align=FILL_HORIZ,
                      size_hint_weight=EXPAND_BOTH)
    bx.pack_end(pb3)
    ic1.show()
    pb3.show()

    pb8 = Progressbar(win,
                      style="double",
                      text="Style: double",
                      size_hint_align=FILL_HORIZ,
                      size_hint_weight=EXPAND_BOTH)
    bx.pack_end(pb8)
    pb8.show()

    hbx = Box(win,
              horizontal=True,
              size_hint_weight=EXPAND_BOTH,
              size_hint_align=FILL_BOTH)
    bx.pack_end(hbx)
    hbx.show()

    pb4 = Progressbar(win,
                      horizontal=False,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH,
                      span_size=60,
                      text="Vertical")
    hbx.pack_end(pb4)
    pb4.show()

    pb5 = Progressbar(win,
                      horizontal=False,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_HORIZ,
                      span_size=120,
                      pulse_mode=True,
                      unit_format=None,
                      text="Infinite bounce")
    hbx.pack_end(pb5)
    pb5.show()

    ic2 = Icon(win,
               file=os.path.join(img_path, "logo_small.png"),
               size_hint_aspect=(EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1))

    pb6 = Progressbar(win,
                      horizontal=False,
                      text="Inverted",
                      content=ic2,
                      inverted=True,
                      unit_format="%1.2f%%",
                      span_size=200,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_HORIZ)
    hbx.pack_end(pb6)
    ic2.show()
    pb6.show()

    pb7 = Progressbar(win,
                      style="wheel",
                      text="Style: wheel",
                      pulse_mode=True,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_HORIZ)
    bx.pack_end(pb7)
    pb7.show()

    bt_bx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    bx.pack_end(bt_bx)
    bt_bx.show()

    pbt = (pb1, pb2, pb3, pb4, pb5, pb6, pb7, pb8)

    bt = Button(win, text="Start")
    bt.callback_clicked_add(begin_test, *pbt)
    bt_bx.pack_end(bt)
    bt.show()

    bt = Button(win, text="Stop")
    bt.callback_clicked_add(end_test, *pbt)
    bt_bx.pack_end(bt)
    bt.show()

    win.callback_delete_request_add(clean_up, *pbt)
    win.show()
Example #16
0
def photocam_clicked(obj):
    win = StandardWindow("photocam",
                         "Photocam test",
                         autodel=True,
                         size=(600, 600))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    # Photocam widget
    pc = Photocam(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(pc)
    pc.show()

    # table for buttons
    tb = Table(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(tb)
    tb.show()

    # zoom out btn
    bt = Button(win,
                text="Z -",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.1, 0.1))
    bt.callback_clicked_add(_cb_zoom_out, pc)
    tb.pack(bt, 0, 0, 1, 1)
    bt.show()

    # select file btn
    bt = FileselectorButton(win,
                            text="Select Photo File",
                            size_hint_weight=EXPAND_BOTH,
                            size_hint_align=(0.5, 0.1))
    bt.callback_file_chosen_add(lambda fs, path: pc.file_set(path))
    tb.pack(bt, 1, 0, 1, 1)
    bt.show()

    # zoom in btn
    bt = Button(win,
                text="Z +",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.9, 0.1))
    bt.callback_clicked_add(_cb_zoom_in, pc)
    tb.pack(bt, 2, 0, 1, 1)
    bt.show()

    # progressbar for remote loading
    pb = Progressbar(win,
                     unit_format="loading %.2f %%",
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH)
    tb.pack(pb, 1, 1, 1, 1)

    # Fit btn
    bt = Button(win,
                text="Fit",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.1, 0.9))
    bt.callback_clicked_add(
        lambda b: pc.zoom_mode_set(ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT))
    tb.pack(bt, 0, 2, 1, 1)
    bt.show()

    # load remote url
    bt = Button(win,
                text="Load remote URL (27MB)",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.5, 0.9))
    bt.callback_clicked_add(lambda b: pc.file_set(remote_url))
    tb.pack(bt, 1, 2, 1, 1)
    bt.show()

    pc.callback_download_start_add(_cb_pc_download_start, pb)
    pc.callback_download_done_add(_cb_pc_download_done, pb)
    pc.callback_download_progress_add(_cb_pc_download_progress, pb)
    pc.callback_download_error_add(_cb_pc_download_error, pb)

    # Fill btn
    bt = Button(win,
                text="Fill",
                size_hint_weight=EXPAND_BOTH,
                size_hint_align=(0.9, 0.9))
    bt.callback_clicked_add(
        lambda b: pc.zoom_mode_set(ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL))
    tb.pack(bt, 2, 2, 1, 1)
    bt.show()

    # show the win
    win.show()