Пример #1
0
def box_transition_clicked(obj, item=None):
    win = StandardWindow("box-layout-transition",
                         "Box Layout Transition",
                         autodel=True)

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

    bx = Box(win,
             layout=ELM_BOX_LAYOUT_HORIZONTAL,
             size_hint_align=FILL_BOTH,
             size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(bx)
    bx.show()

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

    bt = Button(win, text="layout: %s" % layout_list[current_layout])
    bt.callback_clicked_add(box_transition_button_cb, bx)
    vbox.pack_end(bt)
    bt.show()

    for i in range(4):
        ic = Icon(win,
                  file=ic_file,
                  resizable=(0, 0),
                  size_hint_align=(0.5, 0.5))
        bx.pack_end(ic)
        ic.show()

    win.show()
def index_clicked(obj):
    win = StandardWindow("index", "Index 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)
    win.resize_object_add(vbox)
    vbox.show()

    # index
    idx = Index(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    idx.callback_delay_changed_add(cb_idx_delay_changed)
    idx.callback_changed_add(cb_idx_changed)
    idx.callback_selected_add(cb_idx_selected)
    win.resize_object_add(idx)
    idx.show()

    # genlist
    itc = GenlistItemClass(item_style="default",
                           text_get_func=gl_text_get)
                           # content_get_func=gl_content_get,
                           # state_get_func=gl_state_get)
    gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(gl)
    gl.show()


    for i in 'ABCDEFGHILMNOPQRSTUVZ':
        for j in 'acegikmo':
            gl_item = gl.item_append(itc, i + j)
            if j == 'a':
                idx_item = idx.item_append(i, cb_idx_item, gl_item)
                idx_item.data["gl_item"] = gl_item

    idx.level_go(0)

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

    hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ)
    vbox.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="autohide_disabled")
    ck.callback_changed_add(lambda ck: idx.autohide_disabled_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="indicator_disabled")
    ck.callback_changed_add(lambda ck: idx.indicator_disabled_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="horizontal")
    ck.callback_changed_add(lambda ck: idx.horizontal_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    win.show()
Пример #3
0
Файл: gui.py Проект: lonid/epack
    def __init__(self, parent):
        DialogWindow.__init__(self, parent, 'epack-info', 'Epack', autodel=True)

        fr = Frame(self, style='pad_large', size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        self.resize_object_add(fr)
        fr.show()

        hbox = Box(self, horizontal=True, padding=(12,12))
        fr.content = hbox
        hbox.show()

        vbox = Box(self, align=(0.0,0.0), padding=(6,6),
                   size_hint_weight=EXPAND_VERT, size_hint_align=FILL_VERT)
        hbox.pack_end(vbox)
        vbox.show()

        # icon + version
        ic = Icon(self, standard='epack', size_hint_min=(64,64))
        vbox.pack_end(ic)
        ic.show()

        lb = Label(self, text=_('Version: %s') % __version__)
        vbox.pack_end(lb)
        lb.show()

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

        # buttons
        bt = Button(self, text=_('Epack'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(utils.INFO))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=_('Website'),size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: utils.xdg_open(utils.GITHUB))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=_('Authors'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(utils.AUTHORS))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=_('License'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(utils.LICENSE))
        vbox.pack_end(bt)
        bt.show()

        # main text
        self.entry = Entry(self, editable=False, scrollable=True, text=utils.INFO,
                        size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.entry.callback_anchor_clicked_add(lambda e,i: utils.xdg_open(i.name))
        hbox.pack_end(self.entry)
        self.entry.show()

        self.resize(400, 200)
        self.show()
Пример #4
0
    def addTab(self, widget, tabName, canClose=True, disabled=False):
        self.tabs.append(widget)

        btn = Button(self.buttonBox, style="anchor", size_hint_align=ALIGN_LEFT)
        btn.text = tabName
        btn.data["widget"] = widget
        btn.disabled = disabled
        btn.callback_clicked_add(self.showTab, widget)
        btn.show()

        icn = Icon(self.buttonBox)
        icn.standard_set("gtk-close")
        icn.show()

        cls = Button(self.buttonBox, content=icn, style="anchor", size_hint_align=ALIGN_LEFT)
        cls.data["widget"] = widget
        cls.callback_clicked_add(self.closeTab)
        cls.disabled = disabled
        if canClose:
            cls.show()

        sep = Separator(self.buttonBox, size_hint_align=ALIGN_LEFT)
        sep.show()

        self.buttonBox.pack_end(btn)
        self.buttonBox.pack_end(cls)
        self.buttonBox.pack_end(sep)

        #Arguments go: btn, cls, sep
        widget.data["close"] = cls
        widget.data["button"] = btn
        widget.data["sep"] = sep
        
        self.showTab(widget=widget)
Пример #5
0
    def __init__(self, parent):
        InnerWindow.__init__(self, parent)

        vbox = Box(self)
        vbox.show()
        self.content = vbox

        title = Label(self, scale=2.0, text='Edone %s' % VERSION)
        title.show()
        vbox.pack_end(title)

        en = Entry(self, text=INFO, editable=False, scrollable=True,
                   size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        en.show()
        vbox.pack_end(en)

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

        close = Button(self, text='Close')
        close.callback_clicked_add(lambda b: self.delete())
        close.show()
        vbox.pack_end(close)

        self.activate()
def index_clicked(obj):
    win = StandardWindow("index", "Index 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)
    win.resize_object_add(vbox)
    vbox.show()

    # index
    idx = Index(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    idx.callback_delay_changed_add(cb_idx_delay_changed)
    idx.callback_changed_add(cb_idx_changed)
    idx.callback_selected_add(cb_idx_selected)
    win.resize_object_add(idx)
    idx.show()

    # genlist
    itc = GenlistItemClass(item_style="default", text_get_func=gl_text_get)
    # content_get_func=gl_content_get,
    # state_get_func=gl_state_get)
    gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(gl)
    gl.show()

    for i in 'ABCDEFGHILMNOPQRSTUVZ':
        for j in 'acegikmo':
            gl_item = gl.item_append(itc, i + j)
            if j == 'a':
                idx_item = idx.item_append(i, cb_idx_item, gl_item)
                idx_item.data["gl_item"] = gl_item

    idx.level_go(0)

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

    hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ)
    vbox.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="autohide_disabled")
    ck.callback_changed_add(lambda ck: idx.autohide_disabled_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="indicator_disabled")
    ck.callback_changed_add(lambda ck: idx.indicator_disabled_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="horizontal")
    ck.callback_changed_add(lambda ck: idx.horizontal_set(ck.state))
    hbox.pack_end(ck)
    ck.show()

    win.show()
Пример #7
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()
Пример #8
0
Файл: gui.py Проект: 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()
Пример #9
0
    def header_row_pack(self, titles):
        """Takes a list (or a tuple) of tuples (string, bool) and packs them to
        the first row of the table."""

        assert isinstance(titles, (list, tuple))
        for _t in titles:
            assert isinstance(_t, tuple)
            assert len(_t) == 2
            title, sortable = _t
            try:
                assert isinstance(title, str)
            except TypeError:
                assert isinstance(title, str)
            assert isinstance(sortable, bool)

        def sort_btn_cb(button, col):
            """ Sort or reverse if sort button pressed. """

            if self.sort_column == col:
                self.reverse()
            else:
                self.sort_by_column(col)

        for count, _t in enumerate(titles):
            title, sortable = _t
            btn = Button(self,
                         size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ,
                         text=title)
            btn.callback_clicked_add(sort_btn_cb, count)
            if not sortable:
                btn.disabled = True
            btn.show()
            self.header_box.pack_end(btn)
            self.header_row.append(btn)

            elm_list = ScrollableList(self,
                                      size_hint_weight=EXPAND_BOTH,
                                      size_hint_align=FILL_BOTH)
            elm_list.policy_set(ELM_SCROLLER_POLICY_AUTO,
                                ELM_SCROLLER_POLICY_OFF)
            elm_list.mode_set(ELM_LIST_EXPAND)
            elm_list.go()
            elm_list.show()
            self.list_box.pack_end(elm_list)
            self.lists.append(elm_list)

        sep = Separator(self)
        sep.show()

        self.header_box.pack_end(sep)
        self.header_box.pack_end(sep)
Пример #10
0
def focus5_clicked(obj, item=None):

    theme_overlay_add(os.path.join(script_path, "test_focus_custom.edj"))

    win = StandardWindow("focus5", "Focus Custom", autodel=True, size=(320, 320))
    win.focus_highlight_enabled = True
    win.focus_highlight_animate = True
    win.focus_highlight_style = "glow"

    fr = Frame(win, style="pad_large",
              size_hint_weight=EXPAND_BOTH);
    win.resize_object_add(fr)
    fr.show()

    bx = Box(fr)
    fr.content = bx
    bx.show()

    chk = Check(bx, text='Enable glow effect on "Glow" Button', state=True,
                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    bx.pack_end(chk)
    chk.show()

    spinner = Spinner(bx, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    bx.pack_end(spinner)
    spinner.show()

    bt = Button(bx, text="Glow Button",
                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    bt.callback_focused_add(_glow_effect_on_cb, win, chk)
    bt.callback_unfocused_add(_glow_effect_off_cb, win, chk)
    bx.pack_end(bt)
    bt.show()

    sp = Separator(bx, horizontal=True,
                   size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
    bx.pack_end(sp)
    sp.show()

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

    for i in range (1, 5):
        bt = Button(bx2, text="Button %d" % i,
                    size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        bx2.pack_end(bt)
        bt.show()

    win.show()
Пример #11
0
def theme_clicked(obj, data=None):

    win = StandardWindow("config", "Theme", autodel=True, size=(400,200))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    box = Box(win)
    box.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
    box.show()
    win.resize_object_add(box)

    bt = Button(win, text = "A button with a custom style")
    bt.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
    bt.style = "my_custom_style"
    bt.show()
    box.pack_end(bt)

    bt = Button(win, text = "A button with default style")
    bt.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
    bt.show()
    box.pack_end(bt)

    sep = Separator(win, horizontal=True)
    sep.show()
    box.pack_end(sep)
    
    hbox = Box(win, horizontal=True)
    hbox.show()
    box.pack_end(hbox)

    bt = Button(win, text = "Add Extension")
    bt.callback_clicked_add(add_ext_clicked_cb)
    bt.show()
    hbox.pack_end(bt)

    bt = Button(win, text = "Remove Extension")
    bt.callback_clicked_add(del_ext_clicked_cb)
    bt.show()
    hbox.pack_end(bt)

    bt = Button(win, text = "Add Overlay")
    bt.callback_clicked_add(add_ovr_clicked_cb)
    bt.show()
    hbox.pack_end(bt)

    bt = Button(win, text = "Remove Overlay")
    bt.callback_clicked_add(del_ovr_clicked_cb)
    bt.show()
    hbox.pack_end(bt)

    win.show()
Пример #12
0
def theme_clicked(obj, data=None):

    win = StandardWindow("config", "Theme", autodel=True, size=(400, 200))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    box = Box(win)
    box.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
    box.show()
    win.resize_object_add(box)

    bt = Button(win, text="A button with a custom style")
    bt.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
    bt.style = "my_custom_style"
    bt.show()
    box.pack_end(bt)

    bt = Button(win, text="A button with default style")
    bt.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
    bt.show()
    box.pack_end(bt)

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

    hbox = Box(win, horizontal=True)
    hbox.show()
    box.pack_end(hbox)

    bt = Button(win, text="Add Extension")
    bt.callback_clicked_add(add_ext_clicked_cb)
    bt.show()
    hbox.pack_end(bt)

    bt = Button(win, text="Remove Extension")
    bt.callback_clicked_add(del_ext_clicked_cb)
    bt.show()
    hbox.pack_end(bt)

    bt = Button(win, text="Add Overlay")
    bt.callback_clicked_add(add_ovr_clicked_cb)
    bt.show()
    hbox.pack_end(bt)

    bt = Button(win, text="Remove Overlay")
    bt.callback_clicked_add(del_ovr_clicked_cb)
    bt.show()
    hbox.pack_end(bt)

    win.show()
Пример #13
0
def fileselector_entry_clicked(obj, item=None):
    win = StandardWindow("fileselector",
                         "File selector test",
                         autodel=True,
                         size=(240, 150))

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

    fse = FileselectorEntry(win,
                            text="Select a file",
                            inwin_mode=False,
                            size_hint_align=FILL_BOTH,
                            size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(fse)
    fse.show()

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

    hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="inwin", state=fse.inwin_mode)
    ck.callback_changed_add(toggle_inwin, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="folder_only", state=fse.folder_only)
    ck.callback_changed_add(toggle_folder_only, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="is_save", state=fse.is_save)
    ck.callback_changed_add(toggle_is_save, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="expandable", state=fse.expandable)
    ck.callback_changed_add(toggle_expandable, fse)
    hbox.pack_end(ck)
    ck.show()

    win.show()
    def header_row_pack(self, titles):

        """Takes a list (or a tuple) of tuples (string, bool) and packs them to
        the first row of the table."""

        assert isinstance(titles, (list, tuple))
        for t in titles:
            assert isinstance(t, tuple)
            assert len(t) == 2
            title, sortable = t
            try:
                assert isinstance(title, basestring)
            except:
                assert isinstance(title, str)
            assert isinstance(sortable, bool)

        def sort_btn_cb(button, col):
            if self.sort_column == col:
                self.reverse()
            else:
                self.sort_by_column(col)

        for count, t in enumerate(titles):
            title, sortable = t
            btn = Button(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ, text=title)
            btn.callback_clicked_add(sort_btn_cb, count)
            if not sortable:
                btn.disabled = True
            btn.show()
            self.header_box.pack_end(btn)
            self.header_row.append(btn)
            
            elm_list = ScrollableGenlist(self, size_hint_weight=EXPAND_BOTH,  size_hint_align=FILL_BOTH)
            elm_list.policy_set(ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF)
            elm_list.mode_set(ELM_LIST_EXPAND)
            #elm_list.go()
            elm_list.show()
            self.list_box.pack_end(elm_list)
            self.lists.append(elm_list)
        
        sep = Separator(self)
        sep.show()
        
        self.header_box.pack_end(sep)
        self.header_box.pack_end(sep)
def fileselector_entry_clicked(obj, item=None):
    win = StandardWindow("fileselector", "File selector test",
                         autodel=True, size=(240, 150))

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

    fse = FileselectorEntry(win, text="Select a file", inwin_mode=False,
                            size_hint_align=FILL_BOTH,
                            size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(fse)
    fse.show()

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

    hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="inwin", state=fse.inwin_mode)
    ck.callback_changed_add(toggle_inwin, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="folder_only", state=fse.folder_only)
    ck.callback_changed_add(toggle_folder_only, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="is_save", state=fse.is_save)
    ck.callback_changed_add(toggle_is_save, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="expandable", state=fse.expandable)
    ck.callback_changed_add(toggle_expandable, fse)
    hbox.pack_end(ck)
    ck.show()

    win.show()
Пример #16
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()
Пример #17
0
    def __init__(self, parent, done_cb, title, text=None, guide=None, not_empty=True):
        self.done_cb = done_cb

        Popup.__init__(self, parent)
        self.part_text_set('title,text', title)

        box = Box(self, padding=(0,4))
        self.content = box
        box.show()

        if text:
            lb = Label(self, text=text)
            box.pack_end(lb)
            lb.show()

        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        if guide is not None:
            en.part_text_set('guide', guide)
        box.pack_end(en)
        en.show()

        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        box.pack_end(sep)
        sep.show()

        b = Button(self, text='Cancel')
        b.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', b)
        b.show()
        
        b = Button(self, text='OK', disabled=not_empty)
        b.callback_clicked_add(self._confirmed_cb, en, done_cb)
        self.part_content_set('button2', b)
        b.show()

        if not_empty is True:
            en.callback_changed_user_add(self._entry_changed, b)

        en.focus = True
        self.show()
def separator_clicked(obj):
    win = StandardWindow("separators", "Separators", autodel=True)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    bx0 = Box(win, size_hint_weight=EXPAND_BOTH, horizontal=True)
    win.resize_object_add(bx0)
    bx0.show()

    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    bx0.pack_end(bx)
    bx.show()

    bt = Button(win, text="Left upper corner")
    bx.pack_end(bt)
    bt.show()

    sp = Separator(win, horizontal=True)
    bx.pack_end(sp)
    sp.show()

    bt = Button(win, text="Left lower corner", disabled=True)
    bx.pack_end(bt)
    bt.show()

    sp = Separator(win)
    bx0.pack_end(sp)
    sp.show()

    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    bx0.pack_end(bx)
    bx.show()

    bt = Button(win, text="Right upper corner", disabled=True)
    bx.pack_end(bt)
    bt.show()

    sp = Separator(win, horizontal=True)
    bx.pack_end(sp)
    sp.show()

    bt = Button(win, text="Right lower corner")
    bx.pack_end(bt)
    bt.show()

    win.show()
Пример #19
0
    def add(self, widget, name, can_close=True, disabled=False):
        '''Add a tab to the tabbed box'''
        self.tabs.append(widget)

        btn = Button(self.button_bx,
                     style="anchor",
                     size_hint_align=ALIGN_LEFT)
        btn.text = name
        btn.data["widget"] = widget
        btn.disabled = disabled
        btn.callback_clicked_add(self.show_tab, widget)
        btn.show()

        icn = Icon(self.button_bx)
        icn.standard_set("gtk-close")
        icn.show()

        cls = Button(self.button_bx,
                     content=icn,
                     style="anchor",
                     size_hint_align=ALIGN_LEFT)
        cls.data["widget"] = widget
        cls.callback_clicked_add(self.cb_close_btn)
        cls.disabled = disabled
        if can_close:
            cls.show()

        sep = Separator(self.button_bx, size_hint_align=ALIGN_LEFT)
        sep.show()

        self.button_bx.pack_end(btn)
        self.button_bx.pack_end(cls)
        self.button_bx.pack_end(sep)

        # Arguments go: btn, cls, sep
        widget.data["close"] = cls
        widget.data["button"] = btn
        widget.data["sep"] = sep

        self.show_tab(widget=widget)
Пример #20
0
    def _initialize(self, parent_widget, show_func, del_func):
        sel_btn = self._sel_btn = Button(parent_widget,
                                         style="anchor",
                                         text=self._name,
                                         size_hint_align=ALIGN_LEFT,
                                         disabled=(not self._canSelect))
        sel_btn.callback_clicked_add(lambda x, y=self.content: show_func(y))
        sel_btn.show()

        icn = Icon(parent_widget, standard="window-close")
        icn.show()

        cls_btn = self._cls_btn = Button(parent_widget,
                                         style="anchor",
                                         content=icn,
                                         size_hint_align=ALIGN_LEFT,
                                         disabled=(not self._canClose))
        cls_btn.callback_clicked_add(lambda x, y=self.content: del_func(y))
        if self._canClose:
            cls_btn.show()

        self._sep = Separator(parent_widget, size_hint_align=ALIGN_LEFT)
        self._sep.show()
Пример #21
0
    def __init__(self, parent, app, branch):
        self.app = app
        self.branch = branch

        Popup.__init__(self, parent)
        self.part_text_set("title,text", "Delete branch")
        self.part_content_set("title,icon", Icon(self, standard="user-trash"))

        # main vertical box
        box = Box(self)
        self.content = box
        box.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        box.pack_end(sep)
        sep.show()

        # label
        en = Entry(
            self,
            editable=False,
            text="%s<br><br><hilight>%s</hilight><br>" % ("Are you sure you want to delete this branch?", branch.name),
            size_hint_expand=EXPAND_BOTH,
            size_hint_fill=FILL_BOTH,
        )
        box.pack_end(en)
        en.show()

        # force checkbox
        ck = Check(
            self,
            text="Force delete (even if not fully merged)",
            size_hint_expand=EXPAND_BOTH,
            size_hint_align=(0.0, 0.5),
        )
        box.pack_end(ck)
        ck.show()
        self.force_chk = ck

        # buttons
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        box.pack_end(sep)
        sep.show()

        bt = Button(self, text="Cancel")
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set("button1", bt)
        bt.show()

        bt = Button(self, text="Delete branch")
        bt.callback_clicked_add(self._delete_btn_cb)
        self.part_content_set("button2", bt)
        bt.show()

        #
        self.show()
    def __init__(self, parent, session):
        self.session = session
        conf = session.conf
        PreferencesDialog.__init__(self, "General")

        limits = Limits(self, session)
        ports = ListenPorts(self, session)
        pe = EncryptionSettings(self, session)
        dlsel = DataStorageSelector(self, conf)

        pad = Rectangle(self.evas)
        pad.color = 0, 0, 0, 0
        pad.size_hint_min = 0, 10

        sep1 = Separator(self)
        sep1.horizontal = True

        chk1 = Check(self)
        chk1.size_hint_align = 0.0, 0.0
        chk1.text = "Delete original .torrent file when added"
        chk1.state = conf.getboolean("Settings", "delete_original")
        chk1.callback_changed_add(lambda x: conf.set("Settings",
            "delete_original", str(bool(chk1.state))))

        chk2 = Check(self)
        chk2.size_hint_align = 0.0, 0.0
        chk2.text = "Ask for confirmation on exit"
        chk2.state = conf.getboolean("Settings", "confirmations")
        chk2.callback_changed_add(lambda x: conf.set("Settings",
            "confirmations", str(bool(chk2.state))))

        sep2 = Separator(self)
        sep2.horizontal = True

        for w in ports, limits, dlsel, pe, pad, sep1, chk1, chk2, sep2:
            w.show()
            self.box.pack_end(w)
Пример #23
0
    def __init__(self, parent, app):
        self.app = app

        Popup.__init__(self, parent)
        self.part_text_set('title,text', 'Save current status')
        self.part_content_set('title,icon', SafeIcon(self, 'git-stash'))

        # main vertical box
        box = Box(self, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.content = box
        box.show()

        # separator
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        box.pack_end(sep)
        sep.show()

        # description
        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Stash description (or empty for the default)')
        en.text = 'WIP on ' + app.repo.status.head_describe
        box.pack_end(en)
        en.show()

        # include untracked
        ck = Check(self, text='Include untracked files', state=True,
                   size_hint_expand=EXPAND_HORIZ, size_hint_align=(0.0,0.5))
        box.pack_end(ck)
        ck.show()

        # separator
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        box.pack_end(sep)
        sep.show()

        # buttons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()

        bt = Button(self, text='Stash', content=SafeIcon(self, 'git-stash'))
        bt.callback_clicked_add(self._stash_clicked_cb, en, ck)
        self.part_content_set('button2', bt)
        bt.show()

        # focus to the entry and show
        en.select_all()
        en.focus = True
        self.show()
Пример #24
0
    def __init__(self, parent, session):
        self.session = session
        conf = session.conf
        PreferencesDialog.__init__(self, "General")

        limits = Limits(self, session)
        ports = ListenPorts(self, session)
        pe = EncryptionSettings(self, session)
        dlsel = DataStorageSelector(self, conf)

        pad = Rectangle(self.evas)
        pad.color = 0, 0, 0, 0
        pad.size_hint_min = 0, 10

        sep1 = Separator(self)
        sep1.horizontal = True

        chk1 = Check(self)
        chk1.size_hint_align = 0.0, 0.0
        chk1.text = "Delete original .torrent file when added"
        chk1.state = conf.getboolean("Settings", "delete_original")
        chk1.callback_changed_add(lambda x: conf.set(
            "Settings", "delete_original", str(bool(chk1.state))))

        chk2 = Check(self)
        chk2.size_hint_align = 0.0, 0.0
        chk2.text = "Ask for confirmation on exit"
        chk2.state = conf.getboolean("Settings", "confirmations")
        chk2.callback_changed_add(lambda x: conf.set(
            "Settings", "confirmations", str(bool(chk2.state))))

        sep2 = Separator(self)
        sep2.horizontal = True

        for w in ports, limits, dlsel, pe, pad, sep1, chk1, chk2, sep2:
            w.show()
            self.box.pack_end(w)
Пример #25
0
def entry_scrolled_clicked(obj, item=None):
    #static Elm_Entry_Filter_Accept_Set digits_filter_data, digits_filter_data2;
    #static Elm_Entry_Filter_Limit_Size limit_filter_data, limit_filter_data2;

    win = StandardWindow("entry-scrolled",
                         "Entry Scrolled",
                         autodel=True,
                         size=(320, 300))

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

    # disabled entry
    en = ScrollableEntry(win,
                         size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ,
                         policy=SCROLL_POLICY_OFF,
                         text="Disabled entry",
                         single_line=True,
                         disabled=True)
    en.show()
    bx.pack_end(en)

    # password entry
    en = ScrollableEntry(win,
                         size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ,
                         policy=SCROLL_POLICY_OFF,
                         password=True,
                         single_line=True,
                         text="Access denied, give up!",
                         disabled=True)
    en.show()
    bx.pack_end(en)

    # multi-line disable entry
    en = ScrollableEntry(win,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH,
                         policy=SCROLL_POLICY_ON,
                         disabled=True)
    en.context_menu_item_add("Hello")
    en.context_menu_item_add("World")
    en.text = "Multi-line disabled entry widget :)<br/>"\
        "We can use markup <b>like this</> for styling and<br/>"\
        "formatting <em>like this</>, as well as<br/>"\
        "<a href=X><link>links in the text</></a>,"\
        "but it won't be editable or clickable."
    en.show()
    bx.pack_end(en)

    sp = Separator(win, horizontal=True)
    bx.pack_end(sp)
    sp.show()

    # Single line selected entry
    en = ScrollableEntry(win,
                         size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ,
                         text="This is a single line",
                         policy=SCROLL_POLICY_OFF,
                         single_line=True)
    en.select_all()
    en.show()
    bx.pack_end(en)

    # Filter test
    en = ScrollableEntry(win,
                         size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ,
                         text="Filter test",
                         policy=SCROLL_POLICY_OFF,
                         single_line=True)
    en.show()
    bx.pack_end(en)

    en.markup_filter_append(my_filter, "test")

    # # Only digits entry
    # en = ScrollableEntry(win)
    # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
    # en.size_hint_align = EVAS_HINT_FILL, 0.5
    # en.text = "01234"
    # en.scrollbar_policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF
    # en.single_line = True
    # en.show()
    # bx.pack_end(en)

    # digits_filter_data.accepted = "0123456789"
    # digits_filter_data.rejected = NULL
    # en.markup_filter_append(elm_entry_filter_accept_set, digits_filter_data)

    # # No digits entry
    # en = ScrollableEntry(win)
    # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
    # en.size_hint_align = EVAS_HINT_FILL, 0.5
    # en.text = "No numbers here"
    # en.scrollbar_policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF
    # en.single_line = True
    # en.show()
    # bx.pack_end(en)

    # digits_filter_data2.accepted = NULL
    # digits_filter_data2.rejected = "0123456789"
    # en.markup_filter_append(elm_entry_filter_accept_set, digits_filter_data2)

    # # Size limited entry
    # en = ScrollableEntry(win)
    # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
    # en.size_hint_align = EVAS_HINT_FILL, 0.5
    # en.text = "Just 20 chars"
    # en.scrollbar_policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF
    # en.single_line = True
    # en.show()
    # bx.pack_end(en)

    # limit_filter_data.max_char_count = 20
    # limit_filter_data.max_byte_count = 0
    # en.markup_filter_append(elm_entry_filter_limit_size, limit_filter_data)

    # # Byte size limited entry
    # en = ScrollableEntry(win)
    # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
    # en.size_hint_align = EVAS_HINT_FILL, 0.5
    # en.text = "And now only 30 bytes"
    # en.policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF
    # en.single_line = True
    # en.show()
    # bx.pack_end(en)

    # limit_filter_data2.max_char_count = 0
    # limit_filter_data2.max_byte_count = 30
    # en.markup_filter_append(elm_entry_filter_limit_size, limit_filter_data2)

    # Single line password entry
    en_p = ScrollableEntry(win,
                           size_hint_weight=EXPAND_HORIZ,
                           size_hint_align=FILL_HORIZ,
                           policy=SCROLL_POLICY_OFF,
                           text="Password here",
                           single_line=True,
                           password=True)
    en_p.show()
    bx.pack_end(en_p)

    # entry with icon/end widgets
    en = ScrollableEntry(win,
                         policy=SCROLL_POLICY_OFF,
                         single_line=True,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH,
                         text="entry with icon and end objects")
    bt = Icon(win,
              standard="home",
              size_hint_min=(48, 48),
              color=(128, 0, 0, 128))
    bt.show()
    en.part_content_set("icon", bt)
    bt = Icon(win,
              standard="delete",
              size_hint_min=(48, 48),
              color=(128, 0, 0, 128))
    bt.show()
    en.part_content_set("end", bt)
    en.show()
    bx.pack_end(en)

    # markup entry
    en = ScrollableEntry(win,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH,
                         policy=SCROLL_POLICY_ON)
    en.text = "This is an entry widget in this window that<br/>"\
        "uses markup <b>like this</> for styling and<br/>"\
        "formatting <em>like this</>, as well as<br/>"\
        "<a href=X><link>links in the text</></a>, so enter text<br/>"\
        "in here to edit it. By them way, links are<br/>"\
        "called <a href=anc-02>Anchors</a> so you will need<br/>"\
        "to refer to them this way. At the end here is a really long "\
        "line to test line wrapping to see if it works. But just in "\
        "case this line is not long enough I will add more here to "\
        "really test it out, as Elementary really needs some "\
        "good testing to see if entry widgets work as advertised."
    en.callback_anchor_clicked_add(scrolled_anchor_test, en)
    en.show()
    bx.pack_end(en)

    bx2 = Box(win,
              horizontal=True,
              size_hint_weight=EXPAND_HORIZ,
              size_hint_align=FILL_BOTH)

    bt = Button(win,
                text="Clear",
                size_hint_align=FILL_BOTH,
                size_hint_weight=EXPAND_HORIZ,
                propagate_events=False,
                focus_allow=False)
    bt.callback_clicked_add(scrolled_entry_bt_1, en)
    bx2.pack_end(bt)
    bt.show()

    bt = Button(win,
                text="Print",
                size_hint_align=FILL_BOTH,
                size_hint_weight=EXPAND_HORIZ,
                propagate_events=False,
                focus_allow=False)
    bt.callback_clicked_add(scrolled_entry_bt_2, en)
    bx2.pack_end(bt)
    bt.show()

    bt = Button(win,
                text="Print pwd",
                size_hint_align=FILL_BOTH,
                size_hint_weight=EXPAND_HORIZ,
                propagate_events=False,
                focus_allow=False)
    bt.callback_clicked_add(scrolled_entry_bt_5, en_p)
    bx2.pack_end(bt)
    bt.show()

    bt = Button(win,
                text="Selection",
                size_hint_align=FILL_BOTH,
                size_hint_weight=EXPAND_HORIZ,
                propagate_events=False,
                focus_allow=False)
    bt.callback_clicked_add(scrolled_entry_bt_3, en)
    bx2.pack_end(bt)
    bt.show()

    bt = Button(win,
                text="Insert",
                size_hint_align=FILL_BOTH,
                size_hint_weight=EXPAND_HORIZ,
                propagate_events=False,
                focus_allow=False)
    bt.callback_clicked_add(scrolled_entry_bt_4, en)
    bx2.pack_end(bt)
    bt.show()

    bx.pack_end(bx2)
    bx2.show()

    win.focus_set(True)
    win.show()
    def __init__(self, parent, title="About", standardicon="dialog-information", \
                        version="N/A", authors="No One", \
                        licen="GPL", webaddress="", info="Something, something, turtles"):

        if AboutWindow.__initialized:
            raise InstanceError("You can't create more than 1 instance of AboutWindow")
        AboutWindow.__initialized = True

        Window.__init__(self, title, ELM_WIN_DIALOG_BASIC, autodel=True)
        self.callback_delete_request_add(self.close_inst)
        background = Background(self, size_hint_weight=EXPAND_BOTH)
        self.resize_object_add(background)
        background.show()

        fr = Frame(self, style='pad_large', size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        self.resize_object_add(fr)
        fr.show()

        hbox = Box(self, horizontal=True, padding=(12,12))
        fr.content = hbox
        hbox.show()

        vbox = Box(self, align=(0.0,0.0), padding=(6,6),
                   size_hint_weight=EXPAND_VERT, size_hint_align=FILL_VERT)
        hbox.pack_end(vbox)
        vbox.show()

        # icon + version
        ic = Icon(self, size_hint_min=(64,64))
        ic.standard_set(standardicon)
        vbox.pack_end(ic)
        ic.show()

        lb = Label(self, text=('Version: %s') % version)
        vbox.pack_end(lb)
        lb.show()

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

        # buttons
        bt = Button(self, text=(title), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(info))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=('Website'),size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: xdg_open(webaddress))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=('Authors'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(authors))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=('License'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(licen))
        vbox.pack_end(bt)
        bt.show()

        # main text
        self.entry = Entry(self, editable=False, scrollable=True, text=info,
                        size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.entry.callback_anchor_clicked_add(lambda e,i: xdg_open(i.name))
        hbox.pack_end(self.entry)
        self.entry.show()

        self.resize(400, 200)
        self.show()
Пример #27
0
def focus4_clicked(obj, item=None):
    win = StandardWindow("focus4", "Focus 4", autodel=True, size=(320, 320))

    win.focus_highlight_enabled = True
    win.focus_highlight_animate = True

    fr = Frame(win, style="pad_large", size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(fr)
    fr.show()

    # First Example - Using Focus Highlight
    bx = Box(fr)
    fr.content = bx
    bx.show()

    tg = Check(bx,
               text="Focus Highlight Enabled (Config)",
               state=True,
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_BOTH)
    tg.callback_changed_add(_highlight_enabled_cb, win)

    bx.pack_end(tg)
    tg.show()

    tg = Check(bx,
               text="Focus Highlight Animate (Config)",
               state=True,
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_BOTH)
    tg.callback_changed_add(_highlight_animate_cb, win)
    bx.pack_end(tg)
    tg.show()

    tg = Check(bx,
               text="Focus Highlight Enabled (Win)",
               state=True,
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_BOTH)
    tg.callback_changed_add(_win_highlight_enabled_cb, win)
    bx.pack_end(tg)
    tg.show()

    tg = Check(bx,
               text="Focus Highlight Animate (Win)",
               state=True,
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_BOTH)
    tg.callback_changed_add(_win_highlight_animate_cb, win)
    bx.pack_end(tg)
    tg.show()

    sp = Separator(win,
                   horizontal=True,
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_BOTH)
    bx.pack_end(sp)
    sp.show()

    # Second Example - Using Custom Chain
    lb = Label(bx,
               text="Custom Chain: Please use tab key to check",
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_BOTH)
    bx.pack_end(lb)
    lb.show()

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

    bt1 = Button(bx2,
                 text="Button 1",
                 size_hint_weight=EXPAND_BOTH,
                 size_hint_align=FILL_BOTH)
    bx2.pack_end(bt1)
    bt1.show()

    bt2 = Button(bx2,
                 text="Button 2",
                 size_hint_weight=EXPAND_BOTH,
                 size_hint_align=FILL_BOTH)
    bx2.pack_end(bt2)
    bt2.show()

    bt3 = Button(bx2,
                 text="Button 3",
                 size_hint_weight=EXPAND_BOTH,
                 size_hint_align=FILL_BOTH)
    bx2.pack_end(bt3)
    bt3.show()

    bt4 = Button(bx2,
                 text="Button 4",
                 size_hint_weight=EXPAND_BOTH,
                 size_hint_align=FILL_BOTH)
    bx2.pack_end(bt4)
    bt4.show()

    bx2.focus_custom_chain = [bt2, bt1, bt4, bt3]

    tg = Check(bx,
               text="Custom Chain",
               state=False,
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_BOTH)
    tg.callback_changed_add(_custom_chain_cb, bx)
    bx.pack_end(tg)
    tg.show()

    win.show()
    def __init__(self,
                 parent_widget,
                 *args,
                 default_path='',
                 default_populate=True,
                 **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.cancel_cb = None
        self.action_cb = None
        self.cb_dir_change = None

        self.threaded_fn = ThreadedFunction()
        # pylint: disable=c-extension-no-member
        self._timer = ecore.Timer(0.02, self.populate_file)

        # Watch key presses for ctrl+l to select entry
        parent_widget.elm_event_callback_add(self.cb_events)

        self.selected_dir = None
        self.show_hidden = False
        self.cur_dir = None
        self.focused_entry = None
        self.dir_only = False
        self.sort_reverse = False
        self.adding_hidden = False
        self.pending_files = deque()
        self.cur_subdirs = []
        self.cur_files = []

        # Mode should be 'save' or 'load'
        self.mode = 'save'

        self.home = os.path.expanduser('~')

        desktop = os.environ.get('XDG_DESKTOP_DIR')
        if desktop:
            self.desktop = desktop
        else:
            self.desktop = self.home + '/Desktop'

        self.root = '/'

        # Label+Entry for File Name
        self.filename_bx = Box(self,
                               size_hint_weight=EXPAND_HORIZ,
                               size_hint_align=FILL_HORIZ)
        self.filename_bx.horizontal = True
        self.filename_bx.show()

        file_label = Label(self,
                           size_hint_weight=(0.15, EVAS_HINT_EXPAND),
                           size_hint_align=FILL_HORIZ)
        file_label.text = 'Filename:'
        file_label.show()

        self.file_entry = Entry(self,
                                size_hint_weight=EXPAND_BOTH,
                                size_hint_align=FILL_HORIZ)
        self.file_entry.single_line_set(True)
        self.file_entry.scrollable_set(True)
        self.file_entry.callback_changed_user_add(self.cb_file_entry)
        self.file_entry.show()

        self.filename_bx.pack_end(file_label)
        self.filename_bx.pack_end(self.file_entry)

        sep = Separator(self,
                        size_hint_weight=EXPAND_HORIZ,
                        size_hint_align=FILL_HORIZ)
        sep.horizontal_set(True)
        sep.show()

        # Label+Entry for File Path
        self.filepath_bx = Box(self,
                               size_hint_weight=EXPAND_HORIZ,
                               size_hint_align=FILL_HORIZ)
        self.filepath_bx.horizontal = True
        self.filepath_bx.show()

        file_label = Label(self,
                           size_hint_weight=(0.15, EVAS_HINT_EXPAND),
                           size_hint_align=FILL_HORIZ)
        file_label.text = 'Current Folder:'
        file_label.show()

        self.filepath_en = Entry(self,
                                 size_hint_weight=EXPAND_BOTH,
                                 size_hint_align=FILL_HORIZ)
        self.filepath_en.single_line_set(True)
        self.filepath_en.scrollable_set(True)
        self.filepath_en.callback_changed_user_add(self.cb_file_entry)
        self.filepath_en.callback_unfocused_add(self.cb_filepath_en)
        self.filepath_en.callback_activated_add(self.cb_filepath_en)
        # Wish this worked. Doesn't seem to do anything
        # Working now EFL 1.22 ?
        self.filepath_en.input_hint_set(ELM_INPUT_HINT_AUTO_COMPLETE)

        if default_path and os.path.isdir(default_path):
            start = default_path
        else:
            start = self.home
        self.filepath_en.show()

        self.filepath_bx.pack_end(file_label)
        self.filepath_bx.pack_end(self.filepath_en)

        self.autocomplete_hover = Hoversel(self, hover_parent=self)
        self.autocomplete_hover.callback_selected_add(self.cb_hover)
        self.autocomplete_hover.show()

        self.file_selector_bx = Panes(self,
                                      content_left_size=0.3,
                                      size_hint_weight=EXPAND_BOTH,
                                      size_hint_align=FILL_BOTH)
        self.file_selector_bx.show()
        # Bookmarks Box contains:
        #
        # - Button - Up Arrow
        # - List - Home/Desktop/Root/GTK bookmarks
        # - Box
        # -- Button - Add Bookmark
        # -- Button - Remove Bookmark
        self.bookmark_bx = Box(self,
                               size_hint_weight=(0.3, EVAS_HINT_EXPAND),
                               size_hint_align=FILL_BOTH)
        self.bookmark_bx.show()

        up_ic = Icon(self,
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH,
                     order_lookup=ELM_ICON_LOOKUP_THEME)
        up_ic.standard_set('arrow-up')
        up_ic.show()

        self.up_btn = Button(self,
                             size_hint_weight=EXPAND_HORIZ,
                             size_hint_align=FILL_HORIZ,
                             content=up_ic)
        self.up_btn.text = 'Up'
        self.up_btn.callback_pressed_add(self.cb_up_btn)
        self.up_btn.show()

        self.bookmarks_lst = List(self,
                                  size_hint_weight=EXPAND_BOTH,
                                  size_hint_align=FILL_BOTH)
        self.bookmarks_lst.callback_activated_add(self.cb_bookmarks_lst)
        self.bookmarks_lst.show()

        self.bookmark_modbox = Box(self,
                                   size_hint_weight=EXPAND_HORIZ,
                                   size_hint_align=FILL_HORIZ)
        self.bookmark_modbox.horizontal = True
        self.bookmark_modbox.show()

        con = Icon(self,
                   size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        con.standard_set('list-add')
        con.show()

        self.add_btn = Button(self,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ,
                              content=con)
        self.add_btn.callback_pressed_add(self.cb_add_btn)
        self.add_btn.disabled = True
        self.add_btn.show()

        con = Icon(self,
                   size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        con.standard_set('list-remove')
        con.show()

        self.rm_btn = Button(self,
                             size_hint_weight=EXPAND_HORIZ,
                             size_hint_align=FILL_HORIZ,
                             content=con)
        self.rm_btn.callback_pressed_add(self.cb_remove)
        self.rm_btn.disabled = True
        self.rm_btn.show()

        self.bookmark_modbox.pack_end(self.add_btn)
        self.bookmark_modbox.pack_end(self.rm_btn)

        self.bookmark_bx.pack_end(self.up_btn)
        self.bookmark_bx.pack_end(self.bookmarks_lst)
        self.bookmark_bx.pack_end(self.bookmark_modbox)

        # Directory List
        self.file_list_bx = Box(self,
                                size_hint_weight=EXPAND_BOTH,
                                size_hint_align=FILL_BOTH)
        self.file_list_bx.show()

        self.file_sort_btn = Button(self,
                                    size_hint_weight=EXPAND_HORIZ,
                                    size_hint_align=FILL_HORIZ)
        self.file_sort_btn.text = u'⬆ Name'
        self.file_sort_btn.callback_pressed_add(self.cb_sort)
        self.file_sort_btn.show()

        self.file_lst = Genlist(self,
                                size_hint_weight=EXPAND_BOTH,
                                size_hint_align=FILL_BOTH,
                                homogeneous=True,
                                mode=ELM_LIST_COMPRESS)
        self.file_lst.callback_activated_add(self.cb_file_lst)
        self.file_lst.show()

        self.preview = preview = Image(self)
        preview.size_hint_align = FILL_BOTH
        preview.show()

        self.file_list_bx.pack_end(self.file_sort_btn)
        self.file_list_bx.pack_end(self.file_lst)
        self.file_list_bx.pack_end(self.preview)

        self.file_selector_bx.part_content_set('left', self.bookmark_bx)
        self.file_selector_bx.part_content_set('right', self.file_list_bx)

        # Cancel and Save/Open button
        self.button_bx = Box(self,
                             size_hint_weight=EXPAND_HORIZ,
                             size_hint_align=(1.0, 0.5))
        self.button_bx.horizontal = True
        self.button_bx.show()

        self.action_ic = Icon(self,
                              size_hint_weight=EXPAND_BOTH,
                              size_hint_align=FILL_BOTH)
        self.action_ic.standard_set('document-save')
        self.action_ic.show()

        self.action_btn = Button(self,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(1.0, 0.5),
                                 content=self.action_ic)
        self.action_btn.text = 'Save  '
        self.action_btn.callback_pressed_add(self.cb_action_btn)
        self.action_btn.show()

        cancel_ic = Icon(self,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        cancel_ic.standard_set('application-exit')
        cancel_ic.show()

        self.cancel_btn = Button(self,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(1.0, 0.5),
                                 content=cancel_ic)
        self.cancel_btn.text = 'Cancel  '
        self.cancel_btn.callback_pressed_add(self.cb_cancel_btn)
        self.cancel_btn.show()

        con = Icon(self,
                   size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        con.standard_set('edit-find')
        con.show()

        self.hidden_btn = Button(self,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(1.0, 0.5),
                                 content=con)
        self.hidden_btn.text = 'Toggle Hidden  '
        self.hidden_btn.callback_pressed_add(self.cb_toggle_hidden)
        self.hidden_btn.show()

        con = Icon(self,
                   size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        con.standard_set('folder-new')
        con.show()

        self.create_dir_btn = Button(self,
                                     size_hint_weight=(0.0, 0.0),
                                     size_hint_align=(1.0, 0.5),
                                     content=con)
        self.create_dir_btn.text = 'Create Folder  '
        self.create_dir_btn.callback_pressed_add(self.cb_create_dir)
        self.create_dir_btn.show()

        self.button_bx.pack_end(self.create_dir_btn)
        self.button_bx.pack_end(self.hidden_btn)
        self.button_bx.pack_end(self.cancel_btn)
        self.button_bx.pack_end(self.action_btn)

        self.pack_end(self.filename_bx)
        self.pack_end(sep)
        self.pack_end(self.filepath_bx)
        self.pack_end(self.autocomplete_hover)
        self.pack_end(self.file_selector_bx)
        self.pack_end(self.button_bx)

        self.populate_bookmarks()

        self.create_popup = Popup(self)
        self.create_popup.part_text_set('title,text', 'Create Folder:')

        self.create_en = Entry(self,
                               size_hint_weight=EXPAND_HORIZ,
                               size_hint_align=FILL_HORIZ)
        self.create_en.single_line_set(True)
        self.create_en.scrollable_set(True)
        self.create_en.show()

        self.create_popup.content = self.create_en

        bt0 = Button(self, text='Create')
        bt0.callback_clicked_add(self.cb_create_folder)
        self.create_popup.part_content_set('button1', bt0)
        bt1 = Button(self, text='Cancel')
        bt1.callback_clicked_add(self.cb_close_popup)
        self.create_popup.part_content_set('button2', bt1)

        self.recent = None  # keeps pylint happy:
        if default_populate:
            self.populate_files(start)
    def __init__(self, parent, title="About", standardicon="dialog-information", \
                        version="N/A", authors="No One", \
                        licen="GPL", webaddress="", info="Something, something, turtles"):
        Window.__init__(self, title, ELM_WIN_DIALOG_BASIC, autodel=True)

        background = Background(self, size_hint_weight=EXPAND_BOTH)
        self.resize_object_add(background)
        background.show()

        fr = Frame(self,
                   style='pad_large',
                   size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        self.resize_object_add(fr)
        fr.show()

        hbox = Box(self, horizontal=True, padding=(12, 12))
        fr.content = hbox
        hbox.show()

        vbox = Box(self,
                   align=(0.0, 0.0),
                   padding=(6, 6),
                   size_hint_weight=EXPAND_VERT,
                   size_hint_align=FILL_VERT)
        hbox.pack_end(vbox)
        vbox.show()

        # icon + version
        ic = Icon(self, size_hint_min=(64, 64))
        ic.standard_set(standardicon)
        vbox.pack_end(ic)
        ic.show()

        lb = Label(self, text=('Version: %s') % version)
        vbox.pack_end(lb)
        lb.show()

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

        # buttons
        bt = Button(self, text=(title), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(info))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=('Website'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: xdg_open(webaddress))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=('Authors'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(authors))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=('License'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(licen))
        vbox.pack_end(bt)
        bt.show()

        # main text
        self.entry = Entry(self,
                           editable=False,
                           scrollable=True,
                           text=info,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.entry.callback_anchor_clicked_add(lambda e, i: xdg_open(i.name))
        hbox.pack_end(self.entry)
        self.entry.show()

        self.resize(400, 200)
        self.show()
Пример #30
0
def entry_scrolled_clicked(obj, item = None):
    #static Elm_Entry_Filter_Accept_Set digits_filter_data, digits_filter_data2;
    #static Elm_Entry_Filter_Limit_Size limit_filter_data, limit_filter_data2;


    win = StandardWindow("entry-scrolled", "Entry Scrolled", autodel=True,
        size=(320, 300))

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

    # disabled entry
    en = ScrollableEntry(win, size_hint_weight=EXPAND_HORIZ,
        size_hint_align=FILL_HORIZ, policy=SCROLL_POLICY_OFF,
        text="Disabled entry", single_line=True, disabled=True)
    en.show()
    bx.pack_end(en)

    # password entry
    en = ScrollableEntry(win, size_hint_weight=EXPAND_HORIZ,
        size_hint_align=FILL_HORIZ, policy=SCROLL_POLICY_OFF,
        password=True, single_line=True, text="Access denied, give up!",
        disabled=True)
    en.show()
    bx.pack_end(en)

    # multi-line disable entry
    en = ScrollableEntry(win, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH, policy=SCROLL_POLICY_ON,
        disabled=True)
    en.context_menu_item_add("Hello")
    en.context_menu_item_add("World")
    en.text = "Multi-line disabled entry widget :)<br/>"\
        "We can use markup <b>like this</> for styling and<br/>"\
        "formatting <em>like this</>, as well as<br/>"\
        "<a href=X><link>links in the text</></a>,"\
        "but it won't be editable or clickable."
    en.show()
    bx.pack_end(en)

    sp = Separator(win, horizontal=True)
    bx.pack_end(sp)
    sp.show()

    # Single line selected entry
    en = ScrollableEntry(win, size_hint_weight=EXPAND_HORIZ,
        size_hint_align=FILL_HORIZ, text="This is a single line",
        policy=SCROLL_POLICY_OFF, single_line=True)
    en.select_all()
    en.show()
    bx.pack_end(en)

    # Filter test
    en = ScrollableEntry(win, size_hint_weight=EXPAND_HORIZ,
        size_hint_align=FILL_HORIZ, text="Filter test",
        policy=SCROLL_POLICY_OFF, single_line=True)
    en.show()
    bx.pack_end(en)

    en.markup_filter_append(my_filter, "test")

    # # Only digits entry
    # en = ScrollableEntry(win)
    # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
    # en.size_hint_align = EVAS_HINT_FILL, 0.5
    # en.text = "01234"
    # en.scrollbar_policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF
    # en.single_line = True
    # en.show()
    # bx.pack_end(en)

    # digits_filter_data.accepted = "0123456789"
    # digits_filter_data.rejected = NULL
    # en.markup_filter_append(elm_entry_filter_accept_set, digits_filter_data)

    # # No digits entry
    # en = ScrollableEntry(win)
    # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
    # en.size_hint_align = EVAS_HINT_FILL, 0.5
    # en.text = "No numbers here"
    # en.scrollbar_policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF
    # en.single_line = True
    # en.show()
    # bx.pack_end(en)

    # digits_filter_data2.accepted = NULL
    # digits_filter_data2.rejected = "0123456789"
    # en.markup_filter_append(elm_entry_filter_accept_set, digits_filter_data2)

    # # Size limited entry
    # en = ScrollableEntry(win)
    # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
    # en.size_hint_align = EVAS_HINT_FILL, 0.5
    # en.text = "Just 20 chars"
    # en.scrollbar_policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF
    # en.single_line = True
    # en.show()
    # bx.pack_end(en)

    # limit_filter_data.max_char_count = 20
    # limit_filter_data.max_byte_count = 0
    # en.markup_filter_append(elm_entry_filter_limit_size, limit_filter_data)

    # # Byte size limited entry
    # en = ScrollableEntry(win)
    # en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
    # en.size_hint_align = EVAS_HINT_FILL, 0.5
    # en.text = "And now only 30 bytes"
    # en.policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF
    # en.single_line = True
    # en.show()
    # bx.pack_end(en)

    # limit_filter_data2.max_char_count = 0
    # limit_filter_data2.max_byte_count = 30
    # en.markup_filter_append(elm_entry_filter_limit_size, limit_filter_data2)

    # Single line password entry
    en_p = ScrollableEntry(win, size_hint_weight=EXPAND_HORIZ,
        size_hint_align=FILL_HORIZ, policy=SCROLL_POLICY_OFF,
        text="Password here", single_line=True, password=True)
    en_p.show()
    bx.pack_end(en_p)

    # entry with icon/end widgets
    en = ScrollableEntry(win, policy=SCROLL_POLICY_OFF,
        single_line=True, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH, text="entry with icon and end objects")
    bt = Icon(win, standard="home", size_hint_min=(48, 48),
        color=(128, 0, 0, 128))
    bt.show()
    en.part_content_set("icon", bt)
    bt = Icon(win, standard="delete", size_hint_min=(48, 48),
        color=(128, 0, 0, 128))
    bt.show()
    en.part_content_set("end", bt)
    en.show()
    bx.pack_end(en)

    # markup entry
    en = ScrollableEntry(win, size_hint_weight=EXPAND_BOTH,
        size_hint_align=FILL_BOTH, policy=SCROLL_POLICY_ON)
    en.text = "This is an entry widget in this window that<br/>"\
        "uses markup <b>like this</> for styling and<br/>"\
        "formatting <em>like this</>, as well as<br/>"\
        "<a href=X><link>links in the text</></a>, so enter text<br/>"\
        "in here to edit it. By them way, links are<br/>"\
        "called <a href=anc-02>Anchors</a> so you will need<br/>"\
        "to refer to them this way. At the end here is a really long "\
        "line to test line wrapping to see if it works. But just in "\
        "case this line is not long enough I will add more here to "\
        "really test it out, as Elementary really needs some "\
        "good testing to see if entry widgets work as advertised."
    en.callback_anchor_clicked_add(scrolled_anchor_test, en)
    en.show()
    bx.pack_end(en)

    bx2 = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ,
        size_hint_align=FILL_BOTH)

    bt = Button(win, text="Clear", size_hint_align=FILL_BOTH,
        size_hint_weight=EXPAND_HORIZ, propagate_events=False,
        focus_allow=False)
    bt.callback_clicked_add(scrolled_entry_bt_1, en)
    bx2.pack_end(bt)
    bt.show()

    bt = Button(win, text="Print", size_hint_align=FILL_BOTH,
        size_hint_weight=EXPAND_HORIZ, propagate_events=False,
        focus_allow=False)
    bt.callback_clicked_add(scrolled_entry_bt_2, en)
    bx2.pack_end(bt)
    bt.show()

    bt = Button(win, text="Print pwd", size_hint_align=FILL_BOTH,
        size_hint_weight=EXPAND_HORIZ, propagate_events=False,
        focus_allow=False)
    bt.callback_clicked_add(scrolled_entry_bt_5, en_p)
    bx2.pack_end(bt)
    bt.show()

    bt = Button(win, text="Selection", size_hint_align=FILL_BOTH,
        size_hint_weight=EXPAND_HORIZ, propagate_events=False,
        focus_allow=False)
    bt.callback_clicked_add(scrolled_entry_bt_3, en)
    bx2.pack_end(bt)
    bt.show()

    bt = Button(win, text="Insert", size_hint_align=FILL_BOTH,
        size_hint_weight=EXPAND_HORIZ, propagate_events=False,
        focus_allow=False)
    bt.callback_clicked_add(scrolled_entry_bt_4, en)
    bx2.pack_end(bt)
    bt.show()

    bx.pack_end(bx2)
    bx2.show()

    win.focus_set(True)
    win.show()
Пример #31
0
def map_clicked(obj):
    win = StandardWindow("map", "Map test", autodel=True, size=(600, 600))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

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

    map_obj = Map(win, zoom=2)
    map_obj.size_hint_weight = EXPAND_BOTH
    map_obj.size_hint_align = FILL_BOTH
    map_obj.callback_tile_load_add(cb_map_load)
    map_obj.callback_tile_loaded_add(cb_map_load)
    map_obj.event_callback_add(EVAS_CALLBACK_MOUSE_DOWN, cb_map_mouse_down)
    vbox.pack_end(map_obj)
    map_obj.show()

    ###
    lb = Label(win, text="load_status: 0 / 0")
    vbox.pack_end(lb)
    lb.show()
    map_obj.data["lb_load_status"] = lb

    ###
    hbox = Box(win, horizontal=True)
    hbox.size_hint_weight = EXPAND_HORIZ
    hbox.size_hint_align = FILL_HORIZ
    vbox.pack_end(hbox)
    hbox.show()

    bt = Button(win, text="Goto")
    bt.callback_clicked_add(cb_btn_goto, map_obj)
    hbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="Zoom +")
    bt.callback_clicked_add(cb_btn_zoom, map_obj, 1)
    hbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="Zoom -")
    bt.callback_clicked_add(cb_btn_zoom, map_obj, -1)
    hbox.pack_end(bt)
    bt.show()

    sl = Slider(win, text="Rotation:", min_max=(0, 360), value=0,
        indicator_format="%3.0f")
    sl.callback_changed_add(cb_slider_rot, map_obj)
    hbox.pack_end(sl)
    sl.show()

    src_type = ELM_MAP_SOURCE_TYPE_TILE
    ho = Hoversel(win, hover_parent=win,
                  text="Tiles: %s" % (map_obj.source_get(src_type)))
    for src in map_obj.sources_get(src_type):
        ho.item_add(src)
    ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Tiles")
    hbox.pack_end(ho)
    ho.show()

    ###
    hbox = Box(win, horizontal=True)
    hbox.size_hint_weight = EXPAND_HORIZ
    hbox.size_hint_align = FILL_HORIZ
    vbox.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="wheel_disabled")
    ck.callback_changed_add(lambda bt: map_obj.wheel_disabled_set(bt.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="paused")
    ck.callback_changed_add(lambda bt: map_obj.paused_set(bt.state))
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="hide overlays")
    ck.callback_changed_add(cb_chk_overlays_hidden, map_obj)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="pause overlays")
    ck.callback_changed_add(cb_chk_overlays_paused, map_obj)
    hbox.pack_end(ck)
    ck.show()

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

    hbox = Box(win, horizontal=True)
    hbox.size_hint_weight = EXPAND_HORIZ
    hbox.size_hint_align = FILL_HORIZ
    vbox.pack_end(hbox)
    hbox.show()

    src_type = ELM_MAP_SOURCE_TYPE_ROUTE
    ho = Hoversel(win, hover_parent=win,
                  text="Routes: %s" % (map_obj.source_get(src_type)))
    for src in map_obj.sources_get(src_type):
        ho.item_add(src)
    ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Routes")
    hbox.pack_end(ho)
    ho.show()

    lb = Label(win, text="Set Start and End point to calculate route")
    hbox.pack_end(lb)
    lb.show()
    map_obj.data["lb_distance"] = lb

    bt = Button(win, text="Calc route")
    bt.callback_clicked_add(cb_btn_calc_route, map_obj)
    hbox.pack_end(bt)
    bt.show()

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

    hbox = Box(win, horizontal=True)
    hbox.size_hint_weight = EXPAND_HORIZ
    hbox.size_hint_align = FILL_HORIZ
    vbox.pack_end(hbox)
    hbox.show()
    
    src_type = ELM_MAP_SOURCE_TYPE_NAME
    ho = Hoversel(win, hover_parent=win,
                  text="Names: %s" % (map_obj.source_get(src_type)))
    for src in map_obj.sources_get(src_type):
        ho.item_add(src)
    ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Names")
    hbox.pack_end(ho)
    ho.show()

    en = Entry(win, scrollable=True, text="type an address here")
    en.size_hint_weight = EXPAND_BOTH
    en.size_hint_align = FILL_BOTH
    en.single_line = True
    hbox.pack_end(en)
    en.show()

    bt = Button(win, text="Search address")
    bt.callback_clicked_add(cb_btn_search_name, map_obj, en)
    hbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="Search start point")
    bt.callback_clicked_add(cb_btn_search_region, map_obj, en)
    hbox.pack_end(bt)
    bt.show()


    print_map_info(map_obj)
    win.show()
Пример #32
0
    def __init__(self, parent_widget, defaultPath="", defaultPopulate=True, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.cancelCallback = None
        self.actionCallback = None
        self.directoryChangeCallback = None
        
        self.threadedFunction = ThreadedFunction()
        self._timer = ecore.Timer(0.02, self.populateFile)

        #Watch key presses for ctrl+l to select entry
        parent_widget.elm_event_callback_add(self.eventsCb)

        self.selectedFolder = None
        self.showHidden = False
        self.currentDirectory = None
        self.focusedEntry = None
        self.folderOnly = False
        self.sortReverse = False
        self.addingHidden = False
        self.pendingFiles = deque()
        self.currentSubFolders = []
        self.currentFiles = []

        #Mode should be "save" or "load"
        self.mode = "save"

        self.home = os.path.expanduser("~")
        self.root = "/"

        #Label+Entry for File Name
        self.filenameBox = Box(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ)
        self.filenameBox.horizontal = True
        self.filenameBox.show()

        fileLabel = Label(self, size_hint_weight=(0.15, EVAS_HINT_EXPAND),
                size_hint_align=FILL_HORIZ)
        fileLabel.text = "Filename:"
        fileLabel.show()

        self.fileEntry = Entry(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_HORIZ)
        self.fileEntry.single_line_set(True)
        self.fileEntry.scrollable_set(True)
        self.fileEntry.callback_changed_user_add(self.fileEntryChanged)
        self.fileEntry.show()

        self.filenameBox.pack_end(fileLabel)
        self.filenameBox.pack_end(self.fileEntry)

        sep = Separator(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ)
        sep.horizontal_set(True)
        sep.show()

        #Label+Entry for File Path
        self.filepathBox = Box(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ)
        self.filepathBox.horizontal = True
        self.filepathBox.show()

        fileLabel = Label(self, size_hint_weight=(0.15, EVAS_HINT_EXPAND),
                size_hint_align=FILL_HORIZ)
        fileLabel.text = "Current Folder:"
        fileLabel.show()

        self.filepathEntry = Entry(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_HORIZ)
        self.filepathEntry.single_line_set(True)
        self.filepathEntry.scrollable_set(True)
        self.filepathEntry.callback_changed_user_add(self.fileEntryChanged)
        self.filepathEntry.callback_unfocused_add(self.filepathEditDone)
        self.filepathEntry.callback_activated_add(self.filepathEditDone)
        #Wish this worked. Doesn't seem to do anything
        #self.filepathEntry.input_hint_set(ELM_INPUT_HINT_AUTO_COMPLETE)

        if defaultPath and os.path.isdir(defaultPath):
            startPath = defaultPath
        else:
            startPath = self.home
        self.filepathEntry.show()

        self.filepathBox.pack_end(fileLabel)
        self.filepathBox.pack_end(self.filepathEntry)

        self.autocompleteHover = Hoversel(self, hover_parent=self)
        self.autocompleteHover.callback_selected_add(self.autocompleteSelected)
        #self.autocompleteHover.show()

        self.fileSelectorBox = Panes(self, content_left_size=0.3,
                      size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.fileSelectorBox.show()

        """Bookmarks Box contains:

            - Button - Up Arrow
            - List - Home/Root/GTK bookmarks
            - Box
            -- Button - Add Bookmark
            -- Button - Remove Bookmark"""
        self.bookmarkBox = Box(self, size_hint_weight=(0.3, EVAS_HINT_EXPAND),
                size_hint_align=FILL_BOTH)
        self.bookmarkBox.show()


        upIcon = Icon(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
        upIcon.standard_set("go-up")
        upIcon.show()

        self.upButton = Button(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ, content=upIcon)
        self.upButton.text = "Up"
        self.upButton.callback_pressed_add(self.upButtonPressed)
        self.upButton.show()

        self.bookmarksList = List(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
        self.bookmarksList.callback_activated_add(self.bookmarkDoubleClicked)
        self.bookmarksList.show()

        self.bookmarkModBox = Box(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ)
        self.bookmarkModBox.horizontal = True
        self.bookmarkModBox.show()

        con = Icon(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
        con.standard_set("add")
        con.show()

        self.addButton = Button(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ, content=con)
        self.addButton.callback_pressed_add(self.addButtonPressed)
        self.addButton.disabled = True
        self.addButton.show()

        con = Icon(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
        con.standard_set("remove")
        con.show()

        self.removeButton = Button(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ, content=con)
        self.removeButton.callback_pressed_add(self.removeButtonPressed)
        self.removeButton.disabled = True
        self.removeButton.show()

        self.bookmarkModBox.pack_end(self.addButton)
        self.bookmarkModBox.pack_end(self.removeButton)

        self.bookmarkBox.pack_end(self.upButton)
        self.bookmarkBox.pack_end(self.bookmarksList)
        self.bookmarkBox.pack_end(self.bookmarkModBox)

        #Directory List
        self.fileListBox = Box(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
        self.fileListBox.show()
        
        self.fileSortButton = Button(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ)
        self.fileSortButton.text = u"⬆ Name"
        self.fileSortButton.callback_pressed_add(self.sortData)
        self.fileSortButton.show()
        
        self.fileList = Genlist(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH, homogeneous=True,
                mode=ELM_LIST_COMPRESS)
        self.fileList.callback_activated_add(self.fileDoubleClicked)
        self.fileList.show()
        
        self.previewImage = previewImage = Image(self)
        #previewImage.size_hint_weight = EXPAND_BOTH
        previewImage.size_hint_align = FILL_BOTH
        previewImage.show()
        
        self.fileListBox.pack_end(self.fileSortButton)
        self.fileListBox.pack_end(self.fileList)
        self.fileListBox.pack_end(self.previewImage)

        self.fileSelectorBox.part_content_set("left", self.bookmarkBox)
        self.fileSelectorBox.part_content_set("right", self.fileListBox)

        #Cancel and Save/Open button
        self.buttonBox = Box(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=(1.0, 0.5))
        self.buttonBox.horizontal = True
        self.buttonBox.show()

        self.actionIcon = Icon(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
        self.actionIcon.standard_set("document-save")
        self.actionIcon.show()

        self.actionButton = Button(self, size_hint_weight=(0.0, 0.0),
                size_hint_align=(1.0, 0.5), content=self.actionIcon)
        self.actionButton.text = "Save  "
        self.actionButton.callback_pressed_add(self.actionButtonPressed)
        self.actionButton.show()

        cancelIcon = Icon(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
        cancelIcon.standard_set("exit")
        cancelIcon.show()

        self.cancelButton = Button(self, size_hint_weight=(0.0, 0.0),
                size_hint_align=(1.0, 0.5), content=cancelIcon)
        self.cancelButton.text = "Cancel  "
        self.cancelButton.callback_pressed_add(self.cancelButtonPressed)
        self.cancelButton.show()

        con = Icon(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
        con.standard_set("gtk-find")
        con.show()

        self.toggleHiddenButton = Button(self, size_hint_weight=(0.0, 0.0),
                size_hint_align=(1.0, 0.5), content=con)
        self.toggleHiddenButton.text = "Toggle Hidden  "
        self.toggleHiddenButton.callback_pressed_add(self.toggleHiddenButtonPressed)
        self.toggleHiddenButton.show()
        
        con = Icon(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
        con.standard_set("folder-new")
        con.show()
        
        self.createFolderButton = Button(self, size_hint_weight=(0.0, 0.0),
                size_hint_align=(1.0, 0.5), content=con)
        self.createFolderButton.text = "Create Folder  "
        self.createFolderButton.callback_pressed_add(self.createFolderButtonPressed)
        self.createFolderButton.show()

        self.buttonBox.pack_end(self.createFolderButton)
        self.buttonBox.pack_end(self.toggleHiddenButton)
        self.buttonBox.pack_end(self.cancelButton)
        self.buttonBox.pack_end(self.actionButton)

        self.pack_end(self.filenameBox)
        self.pack_end(sep)
        self.pack_end(self.filepathBox)
        self.pack_end(self.autocompleteHover)
        self.pack_end(self.fileSelectorBox)
        self.pack_end(self.buttonBox)

        self.populateBookmarks()
        
        self.createPopup = Popup(self)
        self.createPopup.part_text_set("title,text", "Create Folder:")

        self.createEn = en = Entry(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ)
        en.single_line_set(True)
        en.scrollable_set(True)
        en.show()
        
        self.createPopup.content = en

        bt = Button(self, text="Create")
        bt.callback_clicked_add(self.createFolder)
        self.createPopup.part_content_set("button1", bt)

        bt2 = Button(self, text="Cancel")
        bt2.callback_clicked_add(self.closePopup)
        self.createPopup.part_content_set("button2", bt2)

        if defaultPopulate:
            self.populateFiles(startPath)
Пример #33
0
    def __init__(self, parent_widget, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.cancelCallback = None
        self.actionCallback = None

        self.__first_run = True
        self.use_theme = False
        self.override_theme_font_size = True
        self.override_font_size = 14
        self.theme_data = None
        self.default_font = 'Sans'
        self.default_font_style = 'Regular'
        self.default_font_size = 14
        self.selected_font = self.default_font
        self.selected_font_style = self.default_font_style
        self.selected_font_size = self.default_font_size
        self.font_style_str = self.get_text_style(self.selected_font,
                                                  self.selected_font_style,
                                                  self.selected_font_size)
        self.preview_text = 'abcdefghijk ABCDEFGHIJK'
        # Font size min and max
        self.fs_min = 8
        self.fs_max = 72

        lb = Label(self,
                   text="<br><hilight><i>Select Font</i></hilight>",
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_BOTH)
        lb.show()
        self.pack_end(lb)
        sp = Separator(self,
                       horizontal=True,
                       size_hint_weight=EXPAND_HORIZ,
                       size_hint_align=FILL_HORIZ)
        sp.show()
        self.pack_end(sp)
        # A horizontal box to hold our font list and font styles
        fontBox = Box(self,
                      horizontal=True,
                      homogeneous=True,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        fontBox.show()
        self.pack_end(fontBox)
        # A vertical box to hold label and list of font families
        vBoxFL = Box(self,
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH)
        vBoxFL.show()
        fontBox.pack_end(vBoxFL)
        # A vertical box to hold label and list of font styles
        vBoxFS = Box(self,
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH)
        vBoxFS.show()
        fontBox.pack_end(vBoxFS)
        # Generate our needed font data
        #now =time.time()
        fonts = []
        fonts_raw = self.evas.font_available_list()
        # populate with default font families
        #   see elm_font_available_hash_add Function in EFL
        f_families = ['Sans', 'Serif', 'Monospace']
        f_styles = ['Regular', 'Italic', 'Bold', 'Bold Italic']
        fonts_raw += [i + ':style=' + s for i in f_families for s in f_styles]

        self.fonts_hash = {}
        for font in fonts_raw:
            a = font_properties_get(font)
            # if font name contains a '-' a.name will replace with '\\-'
            #   This needs removed to properly display the name
            fn = a.name.replace('\\', '')
            fonts.append(fn)
            if fn in self.fonts_hash:
                self.fonts_hash.setdefault(fn, []).append(a.styles[0])
            else:
                self.fonts_hash[fn] = [a.styles[0]]

        # Deal with some problematic special cases
        for a, s in self.fonts_hash.items():
            #print(a,s)
            if s:
                if len(s) == 1:
                    s[0] = s[0].rstrip()
                    if s[0] == u'regular':
                        s[0] = u'Regular'
                    if s[0] == u'Medium Italic':
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    elif s[0] == u'Italic':
                        if a != u'Romande ADF Script Std':
                            self.fonts_hash.setdefault(a,
                                                       []).append(u'Regular')
                            self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    else:
                        self.fonts_hash.setdefault(a, []).append(u'Italic')
                        self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                elif len(s) == 2:
                    if any(u'Oblique' in w for w in s):
                        if a not in {
                                u'Baskervald ADF Std Heavy',
                                u'Latin Modern Roman Demi'
                        }:
                            self.fonts_hash.setdefault(a, []).append(u'Bold')
                            self.fonts_hash.setdefault(
                                a, []).append(u'Bold Oblique')
                    elif any(u'Italic' in w for w in s):
                        self.fonts_hash.setdefault(a, []).append(u'Bold')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                    else:
                        self.fonts_hash.setdefault(a, []).append(u'Italic')
                        self.fonts_hash.setdefault(a,
                                                   []).append(u'Bold Italic')
                elif len(s) == 3 and set(s) == {
                        u'Bold', u'Oblique', u'Medium'
                }:
                    # case GWMonospace
                    self.fonts_hash.setdefault(a, []).append(u'Bold Oblique')
                elif len(s) == 3 and set(s) == {
                        u'Italic', u'Regular', u'Bold'
                }:
                    # Case Eden Mills
                    self.fonts_hash.setdefault(a, []).append(u'Bold Italic')
                elif len(s) < 4:
                    print("may need fixed Font style for %s: %s" % (a, s))
        #print(self.fonts_hash)

        # for some strange reason many fonts are displayed multiple times. The following lines remove
        # all duplicates and then sort them alphabetically.
        # FIXME: Is this still true
        fonts = list(set(fonts))
        fonts.sort(cmp=locale.strcoll)

        # Elm List for holding font options
        self.font_list = List(self,
                              size_hint_align=FILL_BOTH,
                              size_hint_weight=EXPAND_BOTH,
                              mode=ELM_LIST_LIMIT)
        #self.font_list.callback_selected_add(self.__font_demo_name_set)
        for font in fonts:
            self.font_list.item_append(font.replace('\\', ''))
            if font == self.selected_font:
                font_it = self.font_list.last_item_get()
        #print  (time.time()- now)
        self.font_list.go()
        self.font_list.show()

        font_family_label = Label(self)
        font_family_label.text = "<br><b>Font:</b>"
        font_family_label.show()
        vBoxFL.pack_end(font_family_label)
        vBoxFL.pack_end(self.font_list)

        # Elm List for hold font styles
        self.font_style = List(self,
                               size_hint_align=FILL_BOTH,
                               size_hint_weight=EXPAND_BOTH,
                               mode=ELM_LIST_LIMIT)
        #self.font_style.callback_selected_add(self.__font_demo_style_set)

        self.__reset_font_style_list(font_it.text_get())

        self.font_style.go()
        self.font_style.show()

        font_style_label = Label(self)
        font_style_label.text = "<br><b>Style:</b>"
        font_style_label.show()
        vBoxFS.pack_end(font_style_label)
        vBoxFS.pack_end(self.font_style)

        # A table to hold font size Spinner and set theme default Check
        tb = Table(self,
                   homogeneous=True,
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_HORIZ)
        self.pack_end(tb)
        tb.show()

        # spinner to choose the font size
        self.font_sizer = Spinner(self)
        self.font_sizer.min_max_set(self.fs_min, self.fs_max)
        self.font_sizer.value_set(self.selected_font_size)
        #self.font_sizer.callback_changed_add(self.__font_demo_size_set)
        self.font_sizer.show()
        # Label for Spinner
        font_sizer_label = Label(self)
        font_sizer_label.text = "Font Size:  "
        font_sizer_label.show()

        size_box = Box(self,
                       size_hint_weight=EXPAND_HORIZ,
                       size_hint_align=FILL_HORIZ)
        size_box.horizontal_set(True)
        size_box.pack_end(font_sizer_label)
        size_box.pack_end(self.font_sizer)
        size_box.show()
        tb.pack(size_box, 33, 0, 34, 34)

        self.use_theme_ck = Check(self,
                                  text="Theme Default   ",
                                  size_hint_weight=EXPAND_HORIZ,
                                  size_hint_align=(1, 0.5))
        self.use_theme_ck.callback_changed_add(self.__use_theme_checked)
        self.use_theme_ck.show()
        tb.pack(self.use_theme_ck, 67, 0, 33, 34)

        # Entry to hold sample text
        self.font_demo = Entry(self,
                               single_line=True,
                               editable=False,
                               context_menu_disabled=True,
                               text=self.preview_text,
                               scrollable=True,
                               size_hint_weight=EXPAND_HORIZ,
                               size_hint_align=FILL_HORIZ)
        self.font_demo.show()

        demo_box = Frame(self,
                         size_hint_align=FILL_BOTH,
                         text="Preview:",
                         content=self.font_demo)
        demo_box.show()

        # Fixme: move this shit
        font_it.selected_set(True)
        font_it.show()
        # Ensure focus is on Font List
        self.font_list.focus_set(True)
        self.pack_end(demo_box)

        # cancel and OK buttons
        ok_button = Button(self)
        ok_button.text = "OK"
        ok_button.callback_pressed_add(self.__ok_button_pressed)
        ok_button.show()

        cancel_button = Button(self)
        cancel_button.text = "Cancel"
        cancel_button.callback_pressed_add(self.__cancel_button_pressed)
        cancel_button.show()

        # box for buttons
        button_box = Box(self)
        button_box.horizontal_set(True)
        button_box.show()
        button_box.pack_end(cancel_button)
        button_box.pack_end(ok_button)
        self.pack_end(button_box)
Пример #34
0
    def __init__(self, parent, app, stash=None):
        self.app = app
        self.stash = stash or app.repo.stash[0]
        self.idx = parseint(stash.ref) if stash else 0

        DialogWindow.__init__(self, app.win, 'egitu-stash', 'stash',
                              size=(500,500), autodel=True)

        # main vertical box (inside a padding frame)
        vbox = Box(self, padding=(0, 6), size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        fr = Frame(self, style='pad_medium', size_hint_weight=EXPAND_BOTH)
        self.resize_object_add(fr)
        fr.content = vbox
        fr.show()
        vbox.show()

        # header horizontal box
        hbox = Box(self, horizontal=True,
                   size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
        vbox.pack_end(hbox)
        hbox.show()

        # title
        en = Entry(self, editable=False, scrollable=False,
                    size_hint_expand=EXPAND_HORIZ, size_hint_align=(-1,0.0))
        hbox.pack_end(en)
        en.show()
        self.title_entry = en

        # header separator
        sep = Separator(self)
        hbox.pack_end(sep)
        sep.show()

        # navigation table
        tb = Table(self, size_hint_align=(0.5,0.0))
        hbox.pack_end(tb)
        tb.show()

        lb = Label(self)
        tb.pack(lb, 0, 0, 2, 1)
        lb.show()
        self.nav_label = lb

        ic = SafeIcon(self, 'go-previous')
        bt = Button(self, text='Prev', content=ic)
        bt.callback_clicked_add(self._prev_clicked_cb)
        tb.pack(bt, 0, 1, 1, 1)
        bt.show()
        self.prev_btn = bt

        ic = SafeIcon(self, 'go-next')
        bt = Button(self, text='Next', content=ic)
        bt.callback_clicked_add(self._next_clicked_cb)
        tb.pack(bt, 1, 1, 1, 1)
        bt.show()
        self.next_btn = bt

        # diff entry
        self.diff_entry = DiffedEntry(self)
        vbox.pack_end(self.diff_entry)
        self.diff_entry.show()

        # buttons
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        vbox.pack_end(sep)
        sep.show()

        hbox = Box(self, horizontal=True,
                   size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_BOTH)
        vbox.pack_end(hbox)
        hbox.show()

        bt = Button(self, text='Apply')
        bt.callback_clicked_add(self._apply_clicked_cb)
        hbox.pack_end(bt)
        bt.show()

        bt = Button(self, text='Pop (apply & delete)')
        bt.callback_clicked_add(self._pop_clicked_cb)
        hbox.pack_end(bt)
        bt.show()

        bt = Button(self, text='Branch & Delete',
                    content=SafeIcon(self, 'git-branch'))
        bt.callback_clicked_add(self._branch_clicked_cb)
        hbox.pack_end(bt)
        bt.show()

        bt = Button(self, text='Delete',
                    content=SafeIcon(self, 'user-trash'))
        bt.callback_clicked_add(self._drop_clicked_cb)
        hbox.pack_end(bt)
        bt.show()

        sep = Separator(self, size_hint_expand=EXPAND_HORIZ)
        hbox.pack_end(sep)

        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        hbox.pack_end(bt)
        bt.show()

        # request the diff and show the dialog
        self.update(self.idx)
        self.show()
Пример #35
0
    def __init__(self,
                 parent,
                 title='About',
                 standardicon='dialog-information',
                 version='N/A',
                 authors='No One',
                 licen='GPL',
                 webaddress='',
                 info='Something, something, turtles'):

        if AboutWindow.__initialized:
            raise InstanceError(
                "You can't create more than 1 instance of AboutWindow")
        AboutWindow.__initialized = True
        self.parent = parent
        Window.__init__(self, title, ELM_WIN_DIALOG_BASIC, autodel=True)
        self.callback_delete_request_add(self.cb_close)
        background = Background(self, size_hint_weight=EXPAND_BOTH)
        self.resize_object_add(background)
        background.show()

        frame = Frame(self,
                      style='pad_large',
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        self.resize_object_add(frame)
        frame.show()

        hbox = Box(self, horizontal=True, padding=(12, 12))
        frame.content = hbox
        hbox.show()

        vbox = Box(self,
                   align=(0.0, 0.0),
                   padding=(6, 6),
                   size_hint_weight=EXPAND_VERT,
                   size_hint_align=FILL_VERT)
        hbox.pack_end(vbox)
        vbox.show()

        # icon + version
        icon = Icon(self, size_hint_min=(64, 64))
        icon.standard_set(standardicon)
        vbox.pack_end(icon)
        icon.show()

        ver_lb = Label(self, text=f'Version: {version}')
        vbox.pack_end(ver_lb)
        ver_lb.show()

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

        # buttons
        btn = Button(self, text=(title), size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(lambda b: self.entry.text_set(info))
        vbox.pack_end(btn)
        btn.show()

        btn = Button(self, text=('Website'), size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(lambda b: xdg_open(webaddress))
        vbox.pack_end(btn)
        btn.show()

        btn = Button(self, text=('Authors'), size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(lambda b: self.entry.text_set(authors))
        vbox.pack_end(btn)
        btn.show()

        btn = Button(self, text=('License'), size_hint_align=FILL_HORIZ)
        btn.callback_clicked_add(lambda b: self.entry.text_set(licen))
        vbox.pack_end(btn)
        btn.show()

        # main text
        self.entry = Entry(self,
                           editable=False,
                           scrollable=True,
                           text=info,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.entry.callback_anchor_clicked_add(lambda e, i: xdg_open(i.name))
        hbox.pack_end(self.entry)
        self.entry.show()

        self.resize(400, 200)
        self.show()
Пример #36
0
    def __init__(self, app):
        self.app = app
        self.prog_popup = None

        # the window
        StandardWindow.__init__(self, 'epack', 'Epack')
        self.autodel_set(True)
        self.callback_delete_request_add(lambda o: self.app.exit())

        ### main table (inside a padding frame)
        frame = Frame(self,
                      style='pad_small',
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        self.resize_object_add(frame)
        frame.content = table = Table(frame)
        frame.show()

        ### header horiz box
        self.header_box = Box(self,
                              horizontal=True,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ)
        table.pack(self.header_box, 0, 0, 3, 1)
        self.header_box.show()

        # genlist with archive content (inside a small padding frame)
        frame = Frame(self,
                      style='pad_small',
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        table.pack(frame, 0, 1, 3, 1)

        self.file_itc = GenlistItemClass(item_style="no_icon",
                                         text_get_func=self._gl_file_text_get)
        self.fold_itc = GenlistItemClass(
            item_style="one_icon",
            text_get_func=self._gl_fold_text_get,
            content_get_func=self._gl_fold_icon_get)
        self.file_list = Genlist(frame, homogeneous=True)
        self.file_list.callback_expand_request_add(self._gl_expand_req_cb)
        self.file_list.callback_contract_request_add(self._gl_contract_req_cb)
        self.file_list.callback_expanded_add(self._gl_expanded_cb)
        self.file_list.callback_contracted_add(self._gl_contracted_cb)
        frame.content = self.file_list
        frame.show()

        # rect hack to force a min size on the genlist
        r = evas.Rectangle(table.evas,
                           size_hint_min=(250, 250),
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        table.pack(r, 0, 1, 3, 1)

        # FileSelectorButton
        self.fsb = DestinationButton(app, self)
        table.pack(self.fsb, 0, 2, 3, 1)
        self.fsb.show()

        sep = Separator(table, horizontal=True, size_hint_weight=EXPAND_HORIZ)
        table.pack(sep, 0, 3, 3, 1)
        sep.show()

        # extract button
        self.extract_btn = Button(table, text=_('Extract'))
        self.extract_btn.callback_clicked_add(self.extract_btn_cb)
        table.pack(self.extract_btn, 0, 4, 1, 2)
        self.extract_btn.show()

        sep = Separator(table, horizontal=False)
        table.pack(sep, 1, 4, 1, 2)
        sep.show()

        # delete-archive checkbox
        self.del_chk = Check(table,
                             text=_('Delete archive after extraction'),
                             size_hint_weight=EXPAND_HORIZ,
                             size_hint_align=(0.0, 1.0))
        self.del_chk.callback_changed_add(self.del_check_cb)
        table.pack(self.del_chk, 2, 4, 1, 1)
        self.del_chk.show()

        # create-archive-folder checkbox
        self.create_folder_chk = Check(table,
                                       text=_('Create archive folder'),
                                       size_hint_weight=EXPAND_HORIZ,
                                       size_hint_align=(0.0, 1.0))
        table.pack(self.create_folder_chk, 2, 5, 1, 1)
        self.create_folder_chk.callback_changed_add(
            lambda c: self.update_fsb_label())
        self.create_folder_chk.show()

        # set the correct ui state
        self.update_ui()

        # show the window
        self.show()
Пример #37
0
    def __init__(self, parent, app):
        self.app = app

        Popup.__init__(self, parent)
        self.part_text_set('title,text', 'Create tag')
        self.part_content_set('title,icon', Icon(self, standard='git-tag'))

        # main vertical box
        tb = Table(self, padding=(4,4),
                    size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.content = tb
        tb.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 0, 2, 1)
        sep.show()

        # tag name
        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Type the tag name, ex: v1.15.0')
        en.callback_changed_user_add(self._something_changed_cb)
        tb.pack(en, 0, 1, 2, 1)
        en.show()
        self.name_entry  = en

        # annotated or light
        rdg = Radio(self, state_value=1, value=1, text='Annotated',
                    size_hint_expand=EXPAND_BOTH)
        rdg.callback_changed_add(self._annotated_radio_changed_cb)
        rdg.callback_changed_add(self._something_changed_cb)
        tb.pack(rdg, 0, 2, 1, 1)
        rdg.show()
        self.annotated_radio  = rdg

        rd = Radio(self, state_value=0, text='Lightweight',
                   size_hint_expand=EXPAND_BOTH)
        rd.callback_changed_add(self._annotated_radio_changed_cb)
        rd.callback_changed_add(self._something_changed_cb)
        rd.group_add(rdg)
        tb.pack(rd, 1, 2, 1, 1)
        rd.show()

        # message entry
        en = Entry(self, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Type a message for the tag')
        en.callback_changed_user_add(self._something_changed_cb)

        r = Rectangle(self.evas, size_hint_min=(200,150),
                      size_hint_expand=EXPAND_BOTH)
        tb.pack(r, 0, 3, 2, 1)
        tb.pack(en, 0, 3, 2, 1)
        en.show()
        self.msg_entry  = en

        # buttons
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 4, 2, 1)
        sep.show()

        bt = Button(self, text='Cancel')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()

        bt = Button(self, text='Create', disabled=True,
                    content=Icon(self, standard='git-tag'))
        bt.callback_clicked_add(self._create_clicked_cb)
        self.part_content_set('button2', bt)
        bt.show()
        self.create_btn = bt

        #
        self.name_entry.focus = True
        self.show()
Пример #38
0
Файл: gui.py Проект: lonid/epack
    def __init__(self, app):
        self.app = app
        self.prog_popup = None

        # the window
        StandardWindow.__init__(self, 'epack', 'Epack')
        self.autodel_set(True)
        self.callback_delete_request_add(lambda o: self.app.exit())

        # main vertical box
        vbox = Box(self, size_hint_weight=EXPAND_BOTH)
        self.resize_object_add(vbox)
        vbox.show()

        ### header horiz box (inside a padding frame)
        frame = Frame(self, style='pad_medium',
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        vbox.pack_end(frame)
        frame.show()

        self.header_box = Box(self, horizontal=True,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ)
        frame.content = self.header_box
        self.header_box.show()

        # genlist with archive content
        self.file_itc = GenlistItemClass(item_style="no_icon",
                                         text_get_func=gl_file_text_get)
        self.fold_itc = GenlistItemClass(item_style="one_icon",
                                         text_get_func=gl_fold_text_get,
                                         content_get_func=gl_fold_icon_get)
        self.file_list = Genlist(self, homogeneous=True,
                                 size_hint_weight=EXPAND_BOTH,
                                 size_hint_align=FILL_BOTH)
        self.file_list.callback_expand_request_add(self._gl_expand_req_cb)
        self.file_list.callback_contract_request_add(self._gl_contract_req_cb)
        self.file_list.callback_expanded_add(self._gl_expanded_cb)
        self.file_list.callback_contracted_add(self._gl_contracted_cb)
        vbox.pack_end(self.file_list)
        self.file_list.show()

        ### footer table (inside a padding frame)
        frame = Frame(self, style='pad_medium',
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        vbox.pack_end(frame)
        frame.show()

        table = Table(frame)
        frame.content = table
        table.show()

        # FileSelectorButton
        self.fsb = DestinationButton(app, self)
        table.pack(self.fsb, 0, 0, 3, 1)
        self.fsb.show()

        sep = Separator(table, horizontal=True,
                        size_hint_weight=EXPAND_HORIZ)
        table.pack(sep, 0, 1, 3, 1)
        sep.show()

        # extract button
        self.extract_btn = Button(table, text=_('Extract'))
        self.extract_btn.callback_clicked_add(self.extract_btn_cb)
        table.pack(self.extract_btn, 0, 2, 1, 2)
        self.extract_btn.show()

        sep = Separator(table, horizontal=False)
        table.pack(sep, 1, 2, 1, 2)
        sep.show()

        # delete-archive checkbox
        self.del_chk = Check(table, text=_('Delete archive after extraction'),
                             size_hint_weight=EXPAND_HORIZ,
                             size_hint_align=(0.0, 1.0))
        self.del_chk.callback_changed_add(self.del_check_cb)
        table.pack(self.del_chk, 2, 2, 1, 1)
        self.del_chk.show()

        # create-archive-folder checkbox
        self.create_folder_chk = Check(table, text=_('Create archive folder'),
                                       size_hint_weight=EXPAND_HORIZ,
                                       size_hint_align=(0.0, 1.0))
        table.pack(self.create_folder_chk, 2, 3, 1, 1)
        self.create_folder_chk.callback_changed_add(
                               lambda c: self.update_fsb_label())
        self.create_folder_chk.show()

        # set the correct ui state
        self.update_ui()

        # show the window
        self.resize(300, 380)
        self.show()
Пример #39
0
    def __init__(self,
                 command=None, win=None,
                 start_callback=None, end_callback=None,
                 *args, **kwargs):
        if not win:
            nowindow = True
            win = self.win = Window("esudo", ELM_WIN_DIALOG_BASIC)
            win.title = "eSudo"
            win.borderless = True
            win.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            win.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            win.resize(300, 200)
            win.callback_delete_request_add(lambda o: elementary.exit())
            win.layer_set(11)
            #~ win.fullscreen = True
            win.show()
            win.activate()

            bg = Background(win)
            bg.size_hint_weight = 1.0, 1.0
            win.resize_object_add(bg)
            bg.show()

            self.embedded = False
        else:
            nowindow = False
            self.embedded = True

        self.cmd = command
        self.start_cb = start_callback if callable(start_callback) else None
        self.end_cb = end_callback if callable(end_callback) else None
        self.args = args
        self.kwargs = kwargs

#--------eSudo Window
        bz = Box(win)
        if nowindow:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        else:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        bz.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.show()

        if nowindow:
            lbl = Label(win)
            lbl.style = "marker"
            lbl.color = 170, 170, 170, 255
            lbl.size_hint_align = 0.5, 0.0
            lbl.scale = 2.0
            lbl.text = "<b>eSudo</b>"
            bz.pack_end(lbl)
            lbl.show()

            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        fr = Frame(win)
        fr.text = "Command:"
        fr.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.pack_end(fr)
        fr.show()

        if nowindow:
            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        self.cmdline = cmdline = Entry(win)
        cmdline.elm_event_callback_add(self.entry_event)
        cmdline.single_line = True
        if self.cmd:
            cmdline.text = self.cmd
            cmdline.editable = False
        fr.content = cmdline
        cmdline.scrollable_set(True)
        cmdline.show()

        if nowindow:
            fr = Frame(win)
            fr.text = "Password:"******"<b>Password:</b>"
            lb.size_hint_align = 0.0, 0.5
            bz1.pack_end(lb)
            lb.show()

        en = self.en = Entry(win)
        en.name = "password"
        en.elm_event_callback_add(self.entry_event)
        en.single_line = True
        en.password = True
        en.show()

        if nowindow:
            fr.content = en
        else:
            bz1.pack_end(en)

        sep = Separator(win)
        sep.horizontal = True
        bz.pack_end(sep)
        sep.show()

        btnb = Box(win)
        btnb.horizontal = True
        btnb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bz.pack_end(btnb)
        btnb.show()

        bt = Button(win)
        bt.text = "Cancel"
        bt.callback_clicked_add(self.esudo_cancel, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        bt = Button(win)
        bt.text = "OK"
        bt.callback_clicked_add(self.password_check, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        self.iw = iw = InnerWindow(win)
        iw.content = bz
        iw.show()
        iw.activate()
        if self.cmd:
            en.focus = True
Пример #40
0
    def __init__(self, parent):
        DialogWindow.__init__(self,
                              parent,
                              'epack-info',
                              'Epack',
                              autodel=True)

        fr = Frame(self,
                   style='pad_large',
                   size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        self.resize_object_add(fr)
        fr.show()

        hbox = Box(self, horizontal=True, padding=(12, 12))
        fr.content = hbox
        hbox.show()

        vbox = Box(self,
                   align=(0.0, 0.0),
                   padding=(6, 6),
                   size_hint_weight=EXPAND_VERT,
                   size_hint_align=FILL_VERT)
        hbox.pack_end(vbox)
        vbox.show()

        # icon + version
        ic = SafeIcon(self, 'epack', size_hint_min=(64, 64))
        vbox.pack_end(ic)
        ic.show()

        lb = Label(self, text=_('Version: %s') % __version__)
        vbox.pack_end(lb)
        lb.show()

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

        # buttons
        bt = Button(self, text=_('Epack'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(utils.INFO))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=_('Website'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: utils.xdg_open(utils.GITHUB))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=_('Authors'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(utils.AUTHORS))
        vbox.pack_end(bt)
        bt.show()

        bt = Button(self, text=_('License'), size_hint_align=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.entry.text_set(utils.LICENSE))
        vbox.pack_end(bt)
        bt.show()

        # main text
        self.entry = Entry(self,
                           editable=False,
                           scrollable=True,
                           text=utils.INFO,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.entry.callback_anchor_clicked_add(
            lambda e, i: utils.xdg_open(i.name))
        hbox.pack_end(self.entry)
        self.entry.show()

        self.resize(400, 200)
        self.show()
Пример #41
0
    def __init__(self, parent, method):
        Popup.__init__(self, parent)
        self._method = method
        self._param_entry = None
        self._return_entry = None

        # title
        self.part_text_set('title,text', 'Method: %s()' % method.name)
        self.show()

        # content is vbox
        vbox = Box(parent)
        vbox.show()
        self.content = vbox

        # params label + entry
        if len(method.params) > 0:
            label = Label(parent)
            label.size_hint_align = 0.0, 0.5
            label.text = 'Params: ' + method.params_str
            label.show()
            vbox.pack_end(label)

            en = Entry(parent)
            self._param_entry = en
            en.editable = True
            en.scrollable = True
            en.single_line = True
            en.entry = ''
            en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            en.show()
            vbox.pack_end(en)

            sp = Separator(win)
            sp.horizontal = True
            sp.show()
            vbox.pack_end(sp)

        # returns label + entry
        label = Label(parent)
        label.size_hint_align = 0.0, 0.5
        label.text = 'Returns: '
        label.text += method.returns_str if method.returns_str else 'None'
        label.show()
        vbox.pack_end(label)

        en = Entry(parent)
        self._return_entry = en
        en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        en.editable = False
        en.scrollable = True
        en.disabled = True
        en.single_line = True  # TODO this is wrong, but the only way to show the entry :/
        en.entry = '<br> <br> <br>'
        en.show()
        vbox.pack_end(en)

        # pretty print check button
        def pretty_output_clicked_cb(chk):
            options.pretty_output = chk.state

        ch = Check(parent)
        ch.size_hint_align = 0.0, 0.5
        ch.text = "Prettify output (loosing type infos)"
        ch.state = options.pretty_output
        ch.callback_changed_add(pretty_output_clicked_cb)
        ch.show()
        vbox.pack_end(ch)

        # popup buttons
        btn = Button(parent)
        btn.text = 'Close'
        btn.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', btn)

        btn = Button(parent)
        btn.text = 'Clear output'
        btn.callback_clicked_add(lambda b: self._return_entry.entry_set(''))
        self.part_content_set('button2', btn)

        btn = Button(parent)
        btn.text = 'Run method'
        btn.callback_clicked_add(self.run_clicked_cb)
        self.part_content_set('button3', btn)
Пример #42
0
    def __init__(self, parent, app):
        self.app = app

        Popup.__init__(self, parent)

        # title
        self.part_text_set('title,text', 'Clone')
        self.part_content_set('title,icon', SafeIcon(self, 'egitu'))

        # main table
        tb = Table(self, padding=(0,4),
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.content = tb
        tb.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        tb.pack(sep, 0, 0, 2, 1)
        sep.show()

        # url
        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Path or URL to clone')
        tb.pack(en, 0, 1, 2, 1)
        en.show()
        self.url_entry = en

        # parent folder
        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        en.part_text_set('guide', 'Parent folder to clone into')
        tb.pack(en, 0, 2, 1, 1)
        en.show()

        bt = Button(self, text='', content=SafeIcon(self, 'folder'))
        bt.callback_clicked_add(self._folder_clicked_cb)
        tb.pack(bt, 1, 2, 1, 1)
        bt.show()
        self.folder_entry = en

        # shallow check
        ck = Check(self, text='Shallow (no history and no branches, faster)',
                   size_hint_expand=EXPAND_BOTH, size_hint_align=(0.0,0.5))
        tb.pack(ck, 0, 3, 2, 1)
        ck.show()
        self.shallow_check = ck

        # output entry
        en = CommandOutputEntry(self, min_size=(400, 150))
        tb.pack(en, 0, 4, 2, 1)
        en.show()
        self.output_entry = en

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ)
        tb.pack(sep, 0, 5, 2, 1)
        sep.show()

        # bottons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()
        self.close_btn = bt

        bt = Button(self, text='Clone')
        bt.callback_clicked_add(self._clone_clicked_cb)
        self.part_content_set('button2', bt)
        bt.show()
        self.clone_btn = bt

        #
        self.show()
Пример #43
0
def focus5_clicked(obj, item=None):

    theme_overlay_add(os.path.join(script_path, "test_focus_custom.edj"))

    win = StandardWindow("focus5",
                         "Focus Custom",
                         autodel=True,
                         size=(320, 320))
    win.focus_highlight_enabled = True
    win.focus_highlight_animate = True
    win.focus_highlight_style = "glow"

    fr = Frame(win, style="pad_large", size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(fr)
    fr.show()

    bx = Box(fr)
    fr.content = bx
    bx.show()

    chk = Check(bx,
                text='Enable glow effect on "Glow" Button',
                state=True,
                size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_BOTH)
    bx.pack_end(chk)
    chk.show()

    spinner = Spinner(bx,
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_BOTH)
    bx.pack_end(spinner)
    spinner.show()

    bt = Button(bx,
                text="Glow Button",
                size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_BOTH)
    bt.callback_focused_add(_glow_effect_on_cb, win, chk)
    bt.callback_unfocused_add(_glow_effect_off_cb, win, chk)
    bx.pack_end(bt)
    bt.show()

    sp = Separator(bx,
                   horizontal=True,
                   size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_BOTH)
    bx.pack_end(sp)
    sp.show()

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

    for i in range(1, 5):
        bt = Button(bx2,
                    text="Button %d" % i,
                    size_hint_weight=EXPAND_BOTH,
                    size_hint_align=FILL_BOTH)
        bx2.pack_end(bt)
        bt.show()

    win.show()
Пример #44
0
    def __init__(self, parent, method):
        StandardWindow.__init__(self, "espionage", "Method", autodel=True)
        self._method = method
        self._param_entry = None
        self._return_entry = None

        # content is vbox (with surrounding pad frame)
        pad = Frame(self, style='pad_medium')
        pad.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        pad.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        self.resize_object_add(pad)
        pad.show()

        vbox = Box(self)
        vbox.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        vbox.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        pad.content = vbox
        vbox.show()

        # title
        f = "font_size=16 align=0.5 font_weight=Bold"
        en = Entry(self, text='<font %s>%s()</>' % (f, method.name))
        en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
        en.size_hint_align = EVAS_HINT_FILL, 0.0
        en.editable = False
        vbox.pack_end(en)
        en.show()

        # params label + entry
        if len(method.params) > 0:
            label = Entry(self, editable=False)
            label.size_hint_weight = EVAS_HINT_EXPAND, 0.0
            label.size_hint_align = EVAS_HINT_FILL, 0.0
            pars = colored_params(method.params, omit_braces=True)
            label.text = 'Params: %s' % (pars if method.params else 'None')
            vbox.pack_end(label)
            label.show()

            en = Entry(self, editable=True, scrollable=True, single_line=True)
            en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
            en.size_hint_align = EVAS_HINT_FILL, 0.0
            self._param_entry = en
            vbox.pack_end(en)
            en.show()

        # returns label + entry
        label = Entry(self, editable=False)
        label.size_hint_weight = EVAS_HINT_EXPAND, 0.0
        label.size_hint_align = EVAS_HINT_FILL, 0.0
        rets = colored_params(method.returns, omit_braces=True)
        label.text = 'Returns: %s' % (rets if method.returns else 'None')
        vbox.pack_end(label)
        label.show()

        en = Entry(self, editable=False, scrollable=True)
        en.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
        en.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
        self._return_entry = en
        vbox.pack_end(en)
        en.show()

        # pretty print check button
        def pretty_output_clicked_cb(chk):
            options.pretty_output = chk.state

        ch = Check(self)
        ch.size_hint_align = 0.0, 0.5
        ch.text = "Prettify output (loosing type infos)"
        ch.state = options.pretty_output
        ch.callback_changed_add(pretty_output_clicked_cb)
        ch.show()
        vbox.pack_end(ch)

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

        # buttons
        hbox = Box(self, horizontal=True)
        hbox.size_hint_weight = EVAS_HINT_EXPAND, 0.0
        hbox.size_hint_align = EVAS_HINT_FILL, 0.5
        vbox.pack_end(hbox)
        hbox.show()

        btn = Button(self)
        btn.text = 'Close'
        btn.callback_clicked_add(lambda b: self.delete())
        hbox.pack_end(btn)
        btn.show()

        btn = Button(self)
        btn.text = 'Clear output'
        btn.callback_clicked_add(lambda b: self._return_entry.entry_set(''))
        hbox.pack_end(btn)
        btn.show()

        btn = Button(self)
        btn.text = 'Run method'
        btn.callback_clicked_add(self.run_clicked_cb)
        hbox.pack_end(btn)
        btn.show()

        # show the window
        self.resize(300, 300)
        self.show()
Пример #45
0
    def __init__(self, parent, app, title, icon_name):
        self.app = app

        Popup.__init__(self, parent)
        self.part_text_set('title,text', title)
        self.part_content_set('title,icon', Icon(self, standard=icon_name))
        
        # TODO padding should be (4,4) but it seems buggy for the big entry
        tb = Table(self, padding=(0,4), size_hint_expand=EXPAND_BOTH)
        self.content = tb
        tb.show()
        self.table = tb

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 0, 2, 1)
        sep.show()

        # remote
        lb = Label(tb, text='Remote', size_hint_align=(0.0, 0.5))
        tb.pack(lb, 0, 1, 1, 1)
        lb.show()

        cb = ComboBox(self, icon=Icon(self, standard='git-remote'))
        cb.callback_selected_add(self.rbranch_populate)
        for remote in app.repo.remotes:
            cb.item_append(remote.name, 'git-remote')
        tb.pack(cb, 1, 1, 1, 1)
        cb.show()
        self.remote_combo = cb

        # remote branch
        lb = Label(tb, text='Remote branch', size_hint_align=(0.0, 0.5))
        tb.pack(lb, 0, 2, 1, 1)
        lb.show()

        cb = ComboBox(self, icon=Icon(cb, standard='git-branch'))
        tb.pack(cb, 1, 2, 1, 1)
        cb.show()
        self.rbranch_combo = cb

        # local branch
        lb = Label(tb, text='Local branch', size_hint_align=(0.0, 0.5))
        tb.pack(lb, 0, 3, 1, 1)
        lb.show()

        en = Entry(tb, disabled=True, single_line=True, scrollable=True,
                   text=app.repo.status.current_branch.name,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        tb.pack(en, 1, 3, 1, 1)
        en.show()
        self.lbranch_entry = en

        # output entry
        en = CommandOutputEntry(self, min_size=(400, 150))
        tb.pack(en, 0, 4, 2, 1)
        en.show()
        self.output_entry = en

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 5, 2, 1)
        sep.show()

        # buttons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()
        self.close_btn = bt

        bt = Button(self, text='Action')
        bt.callback_clicked_add(self._action_btn_cb)
        self.part_content_set('button2', bt)
        bt.show()
        self.action_btn = bt

        self.autopopulate()
        self.show()
def fileselector_clicked(obj, item=None):
    win = StandardWindow("fileselector",
                         "File selector test",
                         autodel=True,
                         size=(500, 500))

    box1 = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(box1)
    box1.show()

    fs = Fileselector(win,
                      is_save=True,
                      expandable=False,
                      folder_only=False,
                      path=os.getenv("HOME"),
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
    fs.callback_done_add(fs_cb_done, win)
    fs.callback_selected_add(fs_cb_selected, win)
    fs.callback_directory_open_add(fs_cb_directory_open, win)
    box1.pack_end(fs)
    fs.show()

    fs.custom_filter_append(custom_filter_all, filter_name="All Files")
    fs.custom_filter_append(custom_filter_edje, filter_name="Edje Files")
    fs.mime_types_filter_append(["text/*"], "Text Files")
    fs.mime_types_filter_append(["image/*"], "Image Files")

    sep = Separator(win)
    box1.pack_end(sep)
    sep.show()

    vbox = Box(win)
    box1.pack_end(vbox)
    vbox.show()

    # Options frame
    fr = Frame(win, text="Options")
    vbox.pack_end(fr)
    fr.show()

    fbox1 = Box(win)
    fr.content = fbox1
    fbox1.show()

    fbox2 = Box(win, horizontal=True)
    fbox1.pack_end(fbox2)
    fbox2.show()

    ck = Check(win, text="is_save", state=fs.is_save)
    ck.callback_changed_add(ck_cb_is_save, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="folder_only", state=fs.folder_only)
    ck.callback_changed_add(ck_cb_folder_only, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="expandable", state=fs.expandable)
    ck.callback_changed_add(ck_cb_expandable, fs)
    fbox2.pack_end(ck)
    ck.show()

    fbox2 = Box(win, horizontal=True)
    fbox1.pack_end(fbox2)
    fbox2.show()

    ck = Check(win, text="multiple selection", state=fs.multi_select)
    ck.callback_changed_add(ck_cb_multi_select, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="buttons", state=fs.buttons_ok_cancel)
    ck.callback_changed_add(ck_cb_buttons, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="hidden", state=fs.hidden_visible)
    ck.callback_changed_add(ck_cb_hidden, fs)
    fbox2.pack_end(ck)
    ck.show()

    # Getters frame
    fr = Frame(win, text="Getters", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    fbox = Box(win, horizontal=True)
    fr.content = fbox
    fbox.show()

    bt = Button(win, text="selected_get")
    bt.callback_clicked_add(bt_cb_sel_get, fs)
    fbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="path_get")
    bt.callback_clicked_add(bt_cb_path_get, fs)
    fbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="selected_paths")
    bt.callback_clicked_add(bt_cb_paths_get, fs)
    fbox.pack_end(bt)
    bt.show()

    # Mode frame
    fr = Frame(win, text="Mode", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    fbox = Box(win, horizontal=True)
    fr.content = fbox
    fbox.show()

    rdg = rd = Radio(win, text="List", state_value=ELM_FILESELECTOR_LIST)
    rd.callback_changed_add(rd_cb_mode, fs)
    fbox.pack_end(rd)
    rd.show()

    rd = Radio(win, text="Grid", state_value=ELM_FILESELECTOR_GRID)
    rd.callback_changed_add(rd_cb_mode, fs)
    rd.group_add(rdg)
    fbox.pack_end(rd)
    rd.show()

    # Thumbsize frame
    fr = Frame(win, text="Thumbnail size", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    sl = Slider(win,
                min_max=(4, 130),
                unit_format="%.0f px",
                value=fs.thumbnail_size[0])
    sl.callback_delay_changed_add(sl_cb_thumb_size, fs)
    fr.content = sl
    sl.show()

    # Sort method frame
    fr = Frame(win, text="Sort method", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    hs = Hoversel(win, text="File name (asc)")
    sorts = (
        ("File name (asc)", ELM_FILESELECTOR_SORT_BY_FILENAME_ASC),
        ("File name (desc)", ELM_FILESELECTOR_SORT_BY_FILENAME_DESC),
        ("Type (asc)", ELM_FILESELECTOR_SORT_BY_TYPE_ASC),
        ("Type (desc)", ELM_FILESELECTOR_SORT_BY_TYPE_DESC),
        ("Size (asc)", ELM_FILESELECTOR_SORT_BY_SIZE_ASC),
        ("Size (desc)", ELM_FILESELECTOR_SORT_BY_SIZE_DESC),
        ("Modified time (asc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_ASC),
        ("Modified time (desc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_DESC),
    )
    for sort in sorts:
        hs.item_add(label=sort[0],
                    callback=hs_cb_sort_method,
                    fs=fs,
                    method=sort[1])
    fr.content = hs
    hs.show()

    win.show()
Пример #47
0
    def __init__(self, app):
        self.app = app

        Popup.__init__(self, app.win)
        self.part_text_set('title,text', 'Discard local changes')
        self.part_content_set('title,icon', Icon(self, standard='user-trash'))

        # main table
        tb = Table(self, padding=(0,4),
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.content = tb
        tb.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 0, 1, 1)
        sep.show()

        # warning label
        en = Entry(self, editable=False,
                   text='<warning>WARNING: This operation is not reversible!</warning><br>' \
                        'Selected files (or ALL files, if nothing is selected) will be ' \
                        'reverted to the state of the last commit.',
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        tb.pack(en, 0, 1, 1, 1)
        en.show()

        # changes list
        r = Rectangle(self.evas, size_hint_min=(300,200),
                      size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        li = List(self, multi_select=True,
                  size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        li.callback_selected_add(self._list_selection_changed_cb)
        li.callback_unselected_add(self._list_selection_changed_cb)
        tb.pack(li, 0, 2, 1, 1)
        tb.pack(r, 0, 2, 1, 1)

        for path in sorted(self.app.repo.status.changes):
            mod, staged, name, new_name = self.app.repo.status.changes[path]
            icon = Icon(self, standard='git-mod-'+mod)
            check = Check(self, text='', state=staged, disabled=True)
            label = '{} → {}'.format(name, new_name) if new_name else name
            it = li.item_append(label, icon, check)
            it.data['mod'] = mod

        li.go()
        li.show()
        self.file_list = li

        # delete untracked check
        ck = Check(self, text='Also delete untracked files', state=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_align=(0.0,0.5))
        tb.pack(ck, 0, 3, 1, 1)
        ck.show()
        self.untracked_chk = ck

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 4, 1, 1)
        sep.show()

        # buttons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()

        bt = Button(self, text="Discard EVERYTHING!",
                    content=Icon(self, standard='user-trash'))
        bt.callback_clicked_add(self._confirm_clicked_cb)
        self.part_content_set('button2', bt)
        bt.show()
        self.confirm_btn = bt

        #
        self.show()
Пример #48
0
    def __init__(self, parent, app, branch=None):
        self.app = app

        Popup.__init__(self, parent)
        self.part_text_set('title,text', 'Create a new local branch')
        self.part_content_set('title,icon', SafeIcon(self, 'git-branch'))

        # main table
        tb = Table(self, padding=(4,4),
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.content = tb
        tb.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 0, 2, 1)
        sep.show()

        # branch name
        lb = Label(self, text='Branch name', size_hint_align=(0.0, 0.5))
        tb.pack(lb, 0, 1, 1, 1)
        lb.show()

        en = Entry(self, single_line=True, scrollable=True,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        tb.pack(en, 1, 1, 1, 1)
        en.show()
        self.name_entry = en

        # branch type
        lb = Label(self, text='Branch type', size_hint_align=(0.0, 0.5))
        tb.pack(lb, 0, 2, 1, 1)
        lb.show()

        hbox = Box(self, horizontal=True, padding=(6,0),
                   size_hint_expand=EXPAND_BOTH, size_hint_align=(0.0, 0.5))
        tb.pack(hbox, 1, 2, 1, 1)
        hbox.show()

        rdg = Radio(self, state_value=0, text='Local branch')
        rdg.callback_changed_add(self._type_radio_changed_cb)
        hbox.pack_end(rdg)
        rdg.show()

        rd = Radio(self, state_value=1, text='Tracking branch')
        rd.callback_changed_add(self._type_radio_changed_cb)
        rd.group_add(rdg)
        hbox.pack_end(rd)
        rd.show()

        self.type_radio = rdg

        # starting revision
        fr = Frame(self, text='Starting revision',
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        tb.pack(fr, 0, 3, 2, 1)
        fr.show()

        r = Rectangle(self.evas, size_hint_min=(300,200),
                      size_hint_expand=EXPAND_BOTH)
        tb.pack(r, 0, 3, 2, 1)

        # TODO: use genlist to speedup population
        self.itc = GenlistItemClass(item_style='one_icon',
                                    text_get_func=self._gl_text_get,
                                    content_get_func=self._gl_content_get)
        li = Genlist(self, homogeneous=True,
                     size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        li.callback_selected_add(self._revision_selected_cb)
        fr.content = li
        li.show()
        self.rev_list = li

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 4, 2, 1)
        sep.show()

        # buttons
        hbox = Box(self, horizontal=True,
                   size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_BOTH)
        tb.pack(hbox, 0, 5, 2, 1)
        hbox.show()

        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        hbox.pack_end(bt)
        bt.show()

        sep = Separator(self, size_hint_expand=EXPAND_HORIZ)
        hbox.pack_end(sep)

        bt = Button(self, text='Create')
        bt.callback_clicked_add(self._create_clicked_cb)
        hbox.pack_end(bt)
        bt.show()

        # populate the revision list and show the popup
        self.populate()
        self.show()
        self.name_entry.focus = True
def fileselector_clicked(obj, item=None):
    win = StandardWindow("fileselector", "File selector test",
                         autodel=True, size=(500,500))

    box1 = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(box1)
    box1.show()

    fs = Fileselector(win, is_save=True, expandable=False, folder_only=False,
                      path=os.getenv("HOME"), size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
    fs.callback_done_add(fs_cb_done, win)
    fs.callback_selected_add(fs_cb_selected, win)
    fs.callback_directory_open_add(fs_cb_directory_open, win)
    box1.pack_end(fs)
    fs.show()

    fs.custom_filter_append(custom_filter_all, filter_name="All Files")
    fs.custom_filter_append(custom_filter_edje, filter_name="Edje Files")
    fs.mime_types_filter_append(["text/*"], "Text Files")
    fs.mime_types_filter_append(["image/*"], "Image Files")


    sep = Separator(win)
    box1.pack_end(sep)
    sep.show()

    vbox = Box(win)
    box1.pack_end(vbox)
    vbox.show()

    # Options frame
    fr = Frame(win, text="Options")
    vbox.pack_end(fr)
    fr.show()

    fbox1 = Box(win)
    fr.content = fbox1
    fbox1.show()

    fbox2 = Box(win, horizontal=True)
    fbox1.pack_end(fbox2)
    fbox2.show()

    ck = Check(win, text="is_save", state=fs.is_save)
    ck.callback_changed_add(ck_cb_is_save, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="folder_only", state=fs.folder_only)
    ck.callback_changed_add(ck_cb_folder_only, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="expandable", state=fs.expandable)
    ck.callback_changed_add(ck_cb_expandable, fs)
    fbox2.pack_end(ck)
    ck.show()

    fbox2 = Box(win, horizontal=True)
    fbox1.pack_end(fbox2)
    fbox2.show()

    ck = Check(win, text="multiple selection", state=fs. multi_select)
    ck.callback_changed_add(ck_cb_multi_select, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="buttons", state=fs.buttons_ok_cancel)
    ck.callback_changed_add(ck_cb_buttons, fs)
    fbox2.pack_end(ck)
    ck.show()

    ck = Check(win, text="hidden", state=fs.hidden_visible)
    ck.callback_changed_add(ck_cb_hidden, fs)
    fbox2.pack_end(ck)
    ck.show()

    # Getters frame
    fr = Frame(win, text="Getters", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    fbox = Box(win, horizontal=True)
    fr.content = fbox
    fbox.show()

    bt = Button(win, text="selected_get")
    bt.callback_clicked_add(bt_cb_sel_get, fs)
    fbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="path_get")
    bt.callback_clicked_add(bt_cb_path_get, fs)
    fbox.pack_end(bt)
    bt.show()

    bt = Button(win, text="selected_paths")
    bt.callback_clicked_add(bt_cb_paths_get, fs)
    fbox.pack_end(bt)
    bt.show()

    # Mode frame
    fr = Frame(win, text="Mode", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    fbox = Box(win, horizontal=True)
    fr.content = fbox
    fbox.show()

    rdg = rd = Radio(win, text="List", state_value=ELM_FILESELECTOR_LIST)
    rd.callback_changed_add(rd_cb_mode, fs)
    fbox.pack_end(rd)
    rd.show()

    rd = Radio(win, text="Grid", state_value=ELM_FILESELECTOR_GRID)
    rd.callback_changed_add(rd_cb_mode, fs)
    rd.group_add(rdg)
    fbox.pack_end(rd)
    rd.show()

    # Thumbsize frame
    fr = Frame(win, text="Thumbnail size", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    sl = Slider(win, min_max=(4, 130), unit_format="%.0f px",
                value=fs.thumbnail_size[0])
    sl.callback_delay_changed_add(sl_cb_thumb_size, fs)
    fr.content = sl
    sl.show()

    # Sort method frame
    fr = Frame(win, text="Sort method", size_hint_align=FILL_BOTH)
    vbox.pack_end(fr)
    fr.show()

    hs = Hoversel(win, text="File name (asc)")
    sorts = (
        ("File name (asc)", ELM_FILESELECTOR_SORT_BY_FILENAME_ASC),
        ("File name (desc)", ELM_FILESELECTOR_SORT_BY_FILENAME_DESC),
        ("Type (asc)", ELM_FILESELECTOR_SORT_BY_TYPE_ASC),
        ("Type (desc)", ELM_FILESELECTOR_SORT_BY_TYPE_DESC),
        ("Size (asc)", ELM_FILESELECTOR_SORT_BY_SIZE_ASC),
        ("Size (desc)", ELM_FILESELECTOR_SORT_BY_SIZE_DESC),
        ("Modified time (asc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_ASC),
        ("Modified time (desc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_DESC),
    )
    for sort in sorts:
        hs.item_add(label=sort[0], callback=hs_cb_sort_method, fs=fs, method=sort[1])
    fr.content = hs
    hs.show()

    win.show()
    def __init__(self, parent, method):
        Popup.__init__(self, parent)
        self._method = method
        self._param_entry = None
        self._return_entry = None

        # title
        self.part_text_set('title,text', 'Method: %s()' % method.name)
        self.show()

        # content is vbox
        vbox = Box(parent)
        vbox.show()
        self.content = vbox

        # params label + entry
        if len(method.params) > 0:
            label = Label(parent)
            label.size_hint_align = 0.0, 0.5
            label.text = 'Params: ' + method.params_str
            label.show()
            vbox.pack_end(label)

            en = Entry(parent)
            self._param_entry = en
            en.editable = True
            en.scrollable = True
            en.single_line = True
            en.entry = ''
            en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            en.show()
            vbox.pack_end(en)

            sp = Separator(win)
            sp.horizontal = True
            sp.show()
            vbox.pack_end(sp)
        
        # returns label + entry
        label = Label(parent)
        label.size_hint_align = 0.0, 0.5
        label.text = 'Returns: '
        label.text += method.returns_str if method.returns_str else 'None'
        label.show()
        vbox.pack_end(label)

        en = Entry(parent)
        self._return_entry = en
        en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        en.editable = False
        en.scrollable = True
        en.disabled = True
        en.single_line = True # TODO this is wrong, but the only way to show the entry :/
        en.entry = '<br> <br> <br>'
        en.show()
        vbox.pack_end(en)

        # pretty print check button
        def pretty_output_clicked_cb(chk):
            options.pretty_output = chk.state
        ch = Check(parent)
        ch.size_hint_align = 0.0, 0.5
        ch.text = "Prettify output (loosing type infos)"
        ch.state = options.pretty_output
        ch.callback_changed_add(pretty_output_clicked_cb)
        ch.show()
        vbox.pack_end(ch)

        # popup buttons
        btn = Button(parent)
        btn.text = 'Close'
        btn.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', btn)

        btn = Button(parent)
        btn.text = 'Clear output'
        btn.callback_clicked_add(lambda b: self._return_entry.entry_set(''))
        self.part_content_set('button2', btn)

        btn = Button(parent)
        btn.text = 'Run method'
        btn.callback_clicked_add(self.run_clicked_cb)
        self.part_content_set('button3', btn)
Пример #51
0
    def __init__(self, app):
        self.app = app

        Popup.__init__(self, app.win)

        # title
        self.part_text_set('title,text', 'Recent Repositories')
        self.part_content_set('title,icon', SafeIcon(self, 'egitu'))

        # main table
        tb = Table(self, padding=(0,4), 
                   size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.content = tb
        tb.show()

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 0, 1, 1)
        sep.show()

        # recent list
        itc = GenlistItemClass(item_style='no_icon',
                               text_get_func=self._gl_text_get)

        li = Genlist(self, homogeneous=True,
                     size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        li.callback_selected_add(self._recent_selected_cb)

        recents = recent_history_get()
        if recents:
            for path in recents:
                li.item_append(itc, path)
        else:
            item = li.item_append(itc, None)
            item.disabled = True
        li.show()

        r = Rectangle(self.evas, color=(0,0,0,0), size_hint_min=(300,200),
                      size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        tb.pack(r, 0, 1, 1, 1)
        tb.pack(li, 0, 1, 1, 1)

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 2, 1, 1)
        sep.show()

        # buttons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)

        bt = Button(self, text='Clone')
        bt.callback_clicked_add(self._clone_btn_cb)
        self.part_content_set('button2', bt)

        bt = Button(self, text='Open')
        bt.callback_clicked_add(self._load_btn_cb)
        self.part_content_set('button3', bt)

        #
        self.show()
Пример #52
0
class Tab(object):

    SEL_COL = (255, 255, 255, 255)
    UNSEL_COL = (128, 128, 128, 128)

    def __init__(self, name, content, canClose=True, canSelect=True):
        self._name = name
        self.content = content
        self._canClose = canClose
        self._canSelect = canSelect
        self._sel_btn = None
        self._cls_btn = None
        self._sep = None

    def __repr__(self):
        return "<%s(name=%r, content=%r, canClose=%r, canSelect=%r)>" % (
            self.__class__.__name__, self._name, self.content.__name__,
            self.canClose, self.canSelect)

    def _initialize(self, parent_widget, show_func, del_func):
        sel_btn = self._sel_btn = Button(parent_widget,
                                         style="anchor",
                                         text=self._name,
                                         size_hint_align=ALIGN_LEFT,
                                         disabled=(not self._canSelect))
        sel_btn.callback_clicked_add(lambda x, y=self.content: show_func(y))
        sel_btn.show()

        icn = Icon(parent_widget, standard="window-close")
        icn.show()

        cls_btn = self._cls_btn = Button(parent_widget,
                                         style="anchor",
                                         content=icn,
                                         size_hint_align=ALIGN_LEFT,
                                         disabled=(not self._canClose))
        cls_btn.callback_clicked_add(lambda x, y=self.content: del_func(y))
        if self._canClose:
            cls_btn.show()

        self._sep = Separator(parent_widget, size_hint_align=ALIGN_LEFT)
        self._sep.show()

    def _delete(self):
        for w in self._sel_btn, self._cls_btn, self._sep:
            w.parent.unpack(w)
            w.delete()

    @property
    def selected(self):
        return True if self._sel_btn.color == self.SEL_COL else False

    @selected.setter
    def selected(self, value):
        self._sel_btn.color = self.SEL_COL if value else self.UNSEL_COL
        self._cls_btn.color = self.SEL_COL if value else self.UNSEL_COL

    @property
    def name(self):
        return self._name

    @name.setter
    def name(self, value):
        self._sel_btn.text = value
        self._name = value

    @property
    def canClose(self):
        return self._canClose

    @canClose.setter
    def canClose(self, value):
        self._canClose = value
        if self._cls_btn is not None:
            self._cls_btn.disabled = not value
            self._cls_btn.visible = value

    @property
    def canSelect(self):
        return self._canSelect

    @canSelect.setter
    def canSelect(self, value):
        self._canSelect = value
        if self._sel_btn is not None:
            self._sel_btn.disabled = not value
Пример #53
0
def label_clicked(obj):
    win = StandardWindow("label", "Label test", autodel=True, size=(280, 400))
    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()

    lb = Label(win, "<b>This is a small label</b>", size_hint_align=(0.0, 0.5))
    vbox.pack_end(lb)
    lb.show()

    lb = Label(win, size_hint_align=(0.0, 0.5))
    lb.text = "This is a larger label with newlines<br/>" \
              "to make it bigger, bit it won't expand or wrap<br/>" \
              "just be a block of text that can't change its<br/>" \
              "formatting as it's fixed based on text<br/>"
    vbox.pack_end(lb)
    lb.show()

    lb = Label(win,
               line_wrap=ELM_WRAP_CHAR,
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_BOTH)
    lb.text =  "<b>This is more text designed to line-wrap here as " \
               "This object is resized horizontally. As it is " \
               "resized vertically though, nothing should change. " \
               "The amount of space allocated vertically should " \
               "change as horizontal size changes.</b>"
    vbox.pack_end(lb)
    lb.show()

    lb = Label(win,
               text="This small label set to wrap",
               size_hint_weight=EXPAND_HORIZ,
               size_hint_align=FILL_BOTH)
    vbox.pack_end(lb)
    lb.show()

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

    gd = Grid(win,
              size=(100, 100),
              size_hint_weight=EXPAND_BOTH,
              size_hint_align=FILL_BOTH)
    vbox.pack_end(gd)
    gd.show()

    lb = Label(win, text="Test Label Ellipsis:", size_hint_align=(0.0, 0.5))
    gd.pack(lb, 5, 5, 90, 15)
    lb.show()

    rect = Rectangle(win.evas, color=(255, 125, 125, 255))
    gd.pack(rect, 5, 15, 90, 15)
    rect.show()

    lb = Label(win, ellipsis=True, size_hint_align=(0.0, 0.5))
    lb.text = "This is a label set to ellipsis. " \
              "If set ellipsis to true and the text doesn't fit " \
              "in the label an ellipsis(\"...\") will be shown " \
              "at the end of the widget."
    gd.pack(lb, 5, 15, 90, 15)
    lb.show()

    lb = Label(win, text="Test Label Slide:", size_hint_align=(0.0, 0.5))
    gd.pack(lb, 5, 30, 90, 15)
    lb.show()

    rect = Rectangle(win.evas, color=(255, 125, 125, 255))
    gd.pack(rect, 5, 40, 90, 15)
    rect.show()

    lb = Label(win,
               slide_mode=ELM_LABEL_SLIDE_MODE_AUTO,
               style="slide_short",
               size_hint_align=(0.0, 0.5),
               slide_duration=15)
    lb.text = "This is a label set to slide. " \
              "If set slide to true the text of the label " \
              "will slide/scroll through the length of label." \
              "This only works with the themes \"slide_short\", " \
              "\"slide_long\" and \"slide_bounce\"."
    gd.pack(lb, 5, 40, 90, 15)
    lb.show()

    rd = Radio(win, state_value=1, text="slide_short")
    gd.pack(rd, 5, 55, 30, 15)
    rd.callback_changed_add(cb_slide_radio, lb)
    rd.show()
    rdg = rd

    rd = Radio(win, state_value=2, text="slide_long")
    rd.group_add(rdg)
    gd.pack(rd, 35, 55, 30, 15)
    rd.callback_changed_add(cb_slide_radio, lb)
    rd.show()

    rd = Radio(win, state_value=3, text="slide_bounce")
    rd.group_add(rdg)
    gd.pack(rd, 65, 55, 30, 15)
    rd.callback_changed_add(cb_slide_radio, lb)
    rd.show()

    sl_dur = Slider(win,
                    text="Slide Duration",
                    unit_format="%1.1f secs",
                    min_max=(1, 40),
                    value=15,
                    size_hint_align=FILL_HORIZ,
                    size_hint_weight=EXPAND_HORIZ)
    sl_dur.callback_changed_add(cb_slider_duration, lb)
    gd.pack(sl_dur, 5, 70, 90, 15)
    sl_dur.show()

    sl_spd = Slider(win,
                    text="Slide Speed",
                    unit_format="%1.1f px/sec",
                    min_max=(10, 300),
                    value=10,
                    size_hint_align=FILL_HORIZ,
                    size_hint_weight=EXPAND_HORIZ)
    sl_spd.callback_changed_add(cb_slider_speed, lb)
    gd.pack(sl_spd, 5, 80, 90, 15)
    sl_spd.show()

    lb.data["slider_duration"] = sl_dur
    lb.data["slider_speed"] = sl_spd

    win.show()
    def __init__(self,
                 parent_widget,
                 defaultPath="",
                 defaultPopulate=True,
                 *args,
                 **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.cancelCallback = None
        self.actionCallback = None
        self.directoryChangeCallback = None

        self.threadedFunction = ThreadedFunction()
        self._timer = ecore.Timer(0.02, self.populateFile)

        #Watch key presses for ctrl+l to select entry
        parent_widget.elm_event_callback_add(self.eventsCb)

        self.selectedFolder = None
        self.showHidden = False
        self.currentDirectory = None
        self.focusedEntry = None
        self.folderOnly = False
        self.sortReverse = False
        self.addingHidden = False
        self.pendingFiles = deque()
        self.currentSubFolders = []
        self.currentFiles = []

        #Mode should be "save" or "load"
        self.mode = "save"

        self.home = os.path.expanduser("~")
        self.root = "/"

        #Label+Entry for File Name
        self.filenameBox = Box(self,
                               size_hint_weight=EXPAND_HORIZ,
                               size_hint_align=FILL_HORIZ)
        self.filenameBox.horizontal = True
        self.filenameBox.show()

        fileLabel = Label(self,
                          size_hint_weight=(0.15, EVAS_HINT_EXPAND),
                          size_hint_align=FILL_HORIZ)
        fileLabel.text = "Filename:"
        fileLabel.show()

        self.fileEntry = Entry(self,
                               size_hint_weight=EXPAND_BOTH,
                               size_hint_align=FILL_HORIZ)
        self.fileEntry.single_line_set(True)
        self.fileEntry.scrollable_set(True)
        self.fileEntry.callback_changed_user_add(self.fileEntryChanged)
        self.fileEntry.show()

        self.filenameBox.pack_end(fileLabel)
        self.filenameBox.pack_end(self.fileEntry)

        sep = Separator(self,
                        size_hint_weight=EXPAND_HORIZ,
                        size_hint_align=FILL_HORIZ)
        sep.horizontal_set(True)
        sep.show()

        #Label+Entry for File Path
        self.filepathBox = Box(self,
                               size_hint_weight=EXPAND_HORIZ,
                               size_hint_align=FILL_HORIZ)
        self.filepathBox.horizontal = True
        self.filepathBox.show()

        fileLabel = Label(self,
                          size_hint_weight=(0.15, EVAS_HINT_EXPAND),
                          size_hint_align=FILL_HORIZ)
        fileLabel.text = "Current Folder:"
        fileLabel.show()

        self.filepathEntry = Entry(self,
                                   size_hint_weight=EXPAND_BOTH,
                                   size_hint_align=FILL_HORIZ)
        self.filepathEntry.single_line_set(True)
        self.filepathEntry.scrollable_set(True)
        self.filepathEntry.callback_changed_user_add(self.fileEntryChanged)
        self.filepathEntry.callback_unfocused_add(self.filepathEditDone)
        self.filepathEntry.callback_activated_add(self.filepathEditDone)
        #Wish this worked. Doesn't seem to do anything
        #self.filepathEntry.input_hint_set(ELM_INPUT_HINT_AUTO_COMPLETE)

        if defaultPath and os.path.isdir(defaultPath):
            startPath = defaultPath
        else:
            startPath = self.home
        self.filepathEntry.show()

        self.filepathBox.pack_end(fileLabel)
        self.filepathBox.pack_end(self.filepathEntry)

        self.autocompleteHover = Hoversel(self, hover_parent=self)
        self.autocompleteHover.callback_selected_add(self.autocompleteSelected)
        #self.autocompleteHover.show()

        self.fileSelectorBox = Panes(self,
                                     content_left_size=0.3,
                                     size_hint_weight=EXPAND_BOTH,
                                     size_hint_align=FILL_BOTH)
        self.fileSelectorBox.show()
        """Bookmarks Box contains:

            - Button - Up Arrow
            - List - Home/Root/GTK bookmarks
            - Box
            -- Button - Add Bookmark
            -- Button - Remove Bookmark"""
        self.bookmarkBox = Box(self,
                               size_hint_weight=(0.3, EVAS_HINT_EXPAND),
                               size_hint_align=FILL_BOTH)
        self.bookmarkBox.show()

        upIcon = Icon(self,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        upIcon.standard_set("go-up")
        upIcon.show()

        self.upButton = Button(self,
                               size_hint_weight=EXPAND_HORIZ,
                               size_hint_align=FILL_HORIZ,
                               content=upIcon)
        self.upButton.text = "Up"
        self.upButton.callback_pressed_add(self.upButtonPressed)
        self.upButton.show()

        self.bookmarksList = List(self,
                                  size_hint_weight=EXPAND_BOTH,
                                  size_hint_align=FILL_BOTH)
        self.bookmarksList.callback_activated_add(self.bookmarkDoubleClicked)
        self.bookmarksList.show()

        self.bookmarkModBox = Box(self,
                                  size_hint_weight=EXPAND_HORIZ,
                                  size_hint_align=FILL_HORIZ)
        self.bookmarkModBox.horizontal = True
        self.bookmarkModBox.show()

        con = Icon(self,
                   size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        con.standard_set("add")
        con.show()

        self.addButton = Button(self,
                                size_hint_weight=EXPAND_HORIZ,
                                size_hint_align=FILL_HORIZ,
                                content=con)
        self.addButton.callback_pressed_add(self.addButtonPressed)
        self.addButton.disabled = True
        self.addButton.show()

        con = Icon(self,
                   size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        con.standard_set("remove")
        con.show()

        self.removeButton = Button(self,
                                   size_hint_weight=EXPAND_HORIZ,
                                   size_hint_align=FILL_HORIZ,
                                   content=con)
        self.removeButton.callback_pressed_add(self.removeButtonPressed)
        self.removeButton.disabled = True
        self.removeButton.show()

        self.bookmarkModBox.pack_end(self.addButton)
        self.bookmarkModBox.pack_end(self.removeButton)

        self.bookmarkBox.pack_end(self.upButton)
        self.bookmarkBox.pack_end(self.bookmarksList)
        self.bookmarkBox.pack_end(self.bookmarkModBox)

        #Directory List
        self.fileListBox = Box(self,
                               size_hint_weight=EXPAND_BOTH,
                               size_hint_align=FILL_BOTH)
        self.fileListBox.show()

        self.fileSortButton = Button(self,
                                     size_hint_weight=EXPAND_HORIZ,
                                     size_hint_align=FILL_HORIZ)
        self.fileSortButton.text = u"⬆ Name"
        self.fileSortButton.callback_pressed_add(self.sortData)
        self.fileSortButton.show()

        self.fileList = Genlist(self,
                                size_hint_weight=EXPAND_BOTH,
                                size_hint_align=FILL_BOTH,
                                homogeneous=True,
                                mode=ELM_LIST_COMPRESS)
        self.fileList.callback_activated_add(self.fileDoubleClicked)
        self.fileList.show()

        self.previewImage = previewImage = Image(self)
        #previewImage.size_hint_weight = EXPAND_BOTH
        previewImage.size_hint_align = FILL_BOTH
        previewImage.show()

        self.fileListBox.pack_end(self.fileSortButton)
        self.fileListBox.pack_end(self.fileList)
        self.fileListBox.pack_end(self.previewImage)

        self.fileSelectorBox.part_content_set("left", self.bookmarkBox)
        self.fileSelectorBox.part_content_set("right", self.fileListBox)

        #Cancel and Save/Open button
        self.buttonBox = Box(self,
                             size_hint_weight=EXPAND_HORIZ,
                             size_hint_align=(1.0, 0.5))
        self.buttonBox.horizontal = True
        self.buttonBox.show()

        self.actionIcon = Icon(self,
                               size_hint_weight=EXPAND_BOTH,
                               size_hint_align=FILL_BOTH)
        self.actionIcon.standard_set("document-save")
        self.actionIcon.show()

        self.actionButton = Button(self,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(1.0, 0.5),
                                   content=self.actionIcon)
        self.actionButton.text = "Save  "
        self.actionButton.callback_pressed_add(self.actionButtonPressed)
        self.actionButton.show()

        cancelIcon = Icon(self,
                          size_hint_weight=EXPAND_BOTH,
                          size_hint_align=FILL_BOTH)
        cancelIcon.standard_set("dialog-cancel")
        cancelIcon.show()

        self.cancelButton = Button(self,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(1.0, 0.5),
                                   content=cancelIcon)
        self.cancelButton.text = "Cancel  "
        self.cancelButton.callback_pressed_add(self.cancelButtonPressed)
        self.cancelButton.show()

        con = Icon(self,
                   size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        con.standard_set("gtk-find")
        con.show()

        self.toggleHiddenButton = Button(self,
                                         size_hint_weight=(0.0, 0.0),
                                         size_hint_align=(1.0, 0.5),
                                         content=con)
        self.toggleHiddenButton.text = "Toggle Hidden  "
        self.toggleHiddenButton.callback_pressed_add(
            self.toggleHiddenButtonPressed)
        self.toggleHiddenButton.show()

        con = Icon(self,
                   size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        con.standard_set("folder-new")
        con.show()

        self.createFolderButton = Button(self,
                                         size_hint_weight=(0.0, 0.0),
                                         size_hint_align=(1.0, 0.5),
                                         content=con)
        self.createFolderButton.text = "Create Folder  "
        self.createFolderButton.callback_pressed_add(
            self.createFolderButtonPressed)
        self.createFolderButton.show()

        self.buttonBox.pack_end(self.createFolderButton)
        self.buttonBox.pack_end(self.toggleHiddenButton)
        self.buttonBox.pack_end(self.cancelButton)
        self.buttonBox.pack_end(self.actionButton)

        self.pack_end(self.filenameBox)
        self.pack_end(sep)
        self.pack_end(self.filepathBox)
        self.pack_end(self.autocompleteHover)
        self.pack_end(self.fileSelectorBox)
        self.pack_end(self.buttonBox)

        self.populateBookmarks()

        self.createPopup = Popup(self)
        self.createPopup.part_text_set("title,text", "Create Folder:")

        self.createEn = en = Entry(self,
                                   size_hint_weight=EXPAND_HORIZ,
                                   size_hint_align=FILL_HORIZ)
        en.single_line_set(True)
        en.scrollable_set(True)
        en.show()

        self.createPopup.content = en

        bt = Button(self, text="Create")
        bt.callback_clicked_add(self.createFolder)
        self.createPopup.part_content_set("button1", bt)

        bt2 = Button(self, text="Cancel")
        bt2.callback_clicked_add(self.closePopup)
        self.createPopup.part_content_set("button2", bt2)

        if defaultPopulate:
            self.populateFiles(startPath)
Пример #55
0
    def __init__(self,
                 command=None,
                 win=None,
                 start_callback=None,
                 end_callback=None,
                 *args,
                 **kwargs):
        if not win:
            nowindow = True
            win = self.win = Window("esudo", ELM_WIN_DIALOG_BASIC)
            win.title = "eSudo"
            win.borderless = True
            win.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            win.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            win.resize(300, 200)
            win.callback_delete_request_add(lambda o: elementary.exit())
            win.layer_set(11)
            #~ win.fullscreen = True
            win.show()
            win.activate()

            bg = Background(win)
            bg.size_hint_weight = 1.0, 1.0
            win.resize_object_add(bg)
            bg.show()

            self.embedded = False
        else:
            nowindow = False
            self.embedded = True

        self.cmd = command
        self.start_cb = start_callback if callable(start_callback) else None
        self.end_cb = end_callback if callable(end_callback) else None
        self.args = args
        self.kwargs = kwargs

        #--------eSudo Window
        bz = Box(win)
        if nowindow:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        else:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        bz.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.show()

        if nowindow:
            lbl = Label(win)
            lbl.style = "marker"
            lbl.color = 170, 170, 170, 255
            lbl.size_hint_align = 0.5, 0.0
            lbl.scale = 2.0
            lbl.text = "<b>eSudo</b>"
            bz.pack_end(lbl)
            lbl.show()

            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        fr = Frame(win)
        fr.text = "Command:"
        fr.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.pack_end(fr)
        fr.show()

        if nowindow:
            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        self.cmdline = cmdline = Entry(win)
        cmdline.elm_event_callback_add(self.entry_event)
        cmdline.single_line = True
        if self.cmd:
            cmdline.text = self.cmd
            cmdline.editable = False
        fr.content = cmdline
        cmdline.scrollable_set(True)
        cmdline.show()

        if nowindow:
            fr = Frame(win)
            fr.text = "Password:"******"<b>Password:</b>"
            lb.size_hint_align = 0.0, 0.5
            bz1.pack_end(lb)
            lb.show()

        en = self.en = Entry(win)
        en.name = "password"
        en.elm_event_callback_add(self.entry_event)
        en.single_line = True
        en.password = True
        en.show()

        if nowindow:
            fr.content = en
        else:
            bz1.pack_end(en)

        sep = Separator(win)
        sep.horizontal = True
        bz.pack_end(sep)
        sep.show()

        btnb = Box(win)
        btnb.horizontal = True
        btnb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bz.pack_end(btnb)
        btnb.show()

        bt = Button(win)
        bt.text = "Cancel"
        bt.callback_clicked_add(self.esudo_cancel, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        bt = Button(win)
        bt.text = "OK"
        bt.callback_clicked_add(self.password_check, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        self.iw = iw = InnerWindow(win)
        iw.content = bz
        iw.show()
        iw.activate()
        if self.cmd:
            en.focus = True
Пример #56
0
    def __init__(self, windowGrid, name):
        offset = 0
        if (name == 'Yau'):
            offset = 50

        self.BaseBox = Box(windowGrid,
                           size_hint_weight=(EVAS_HINT_EXPAND,
                                             EVAS_HINT_EXPAND),
                           size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL))
        windowGrid.pack(self.BaseBox, offset, 0, 50, 100)
        self.BaseBox.show()

        self.frame = Frame(self.BaseBox,
                           size_hint_weight=(EVAS_HINT_EXPAND,
                                             EVAS_HINT_EXPAND),
                           size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL),
                           text=name)
        self.BaseBox.pack_end(self.frame)
        self.frame.show()

        self.FrameBox = Box(self.BaseBox,
                            size_hint_weight=(EVAS_HINT_EXPAND,
                                              EVAS_HINT_EXPAND),
                            size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL))
        self.frame.content_set(self.FrameBox)
        self.FrameBox.show()

        self.FrameCheck = Check(self.BaseBox,
                                size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                size_hint_align=(EVAS_HINT_FILL, 0.5),
                                text="{0} Frame Check".format(name))
        self.FrameBox.pack_end(self.FrameCheck)
        self.FrameCheck.show()

        self.FrameSeparator = Separator(self.BaseBox,
                                        horizontal=True,
                                        size_hint_weight=(EVAS_HINT_EXPAND,
                                                          0.0),
                                        size_hint_align=(EVAS_HINT_FILL, 0.5))
        self.FrameBox.pack_end(self.FrameSeparator)
        self.FrameSeparator.show()

        self.FrameScroller = Scroller(
            self.BaseBox,
            content_min_limit=(True, False),
            size_hint_weight=(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
            size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL),
            scrollbar_policy=(ELM_SCROLLER_POLICY_OFF,
                              ELM_SCROLLER_POLICY_OFF))
        self.FrameBox.pack_end(self.FrameScroller)
        self.FrameScroller.show()

        self.FrameTable = Table(self.BaseBox,
                                size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                size_hint_align=(EVAS_HINT_FILL, 0.0))
        self.FrameScroller.content_set(self.FrameTable)
        self.FrameTable.show()

        self.BaseLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Base:")
        self.FrameTable.pack(self.BaseLabel, 0, 0, 1, 1)
        self.BaseLabel.show()

        self.BaseEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.BaseEntry, 1, 0, 1, 1)
        self.BaseEntry.show()

        self.SecretLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Secret:")
        self.FrameTable.pack(self.SecretLabel, 2, 0, 1, 1)
        self.SecretLabel.show()

        self.SecretEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.SecretEntry, 3, 0, 1, 1)
        self.SecretEntry.show()

        self.SignalLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Signal:")
        self.FrameTable.pack(self.SignalLabel, 4, 0, 1, 1)
        self.SignalLabel.show()

        self.SignalEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.SignalEntry, 5, 0, 1, 1)
        self.SignalEntry.show()

        self.ChannelLabel = Label(self.FrameTable,
                                  size_hint_weight=(0.0, 0.0),
                                  size_hint_align=(0.0, 0.5),
                                  text="Channel:")
        self.FrameTable.pack(self.ChannelLabel, 0, 1, 1, 1)
        self.ChannelLabel.show()

        self.ChannelEntry = Entry(self.FrameTable,
                                  size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                  size_hint_align=(EVAS_HINT_FILL, 0.5),
                                  single_line=True,
                                  scrollable=True,
                                  text="")
        self.FrameTable.pack(self.ChannelEntry, 1, 1, 1, 1)
        self.ChannelEntry.show()

        self.PoleLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Pole:")
        self.FrameTable.pack(self.PoleLabel, 2, 1, 1, 1)
        self.PoleLabel.show()

        self.PoleEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.PoleEntry, 3, 1, 1, 1)
        self.PoleEntry.show()

        self.IdentityLabel = Label(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Identity:")
        self.FrameTable.pack(self.IdentityLabel, 4, 1, 1, 1)
        self.IdentityLabel.show()

        self.IdentityEntry = Entry(self.FrameTable,
                                   size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                   size_hint_align=(EVAS_HINT_FILL, 0.5),
                                   single_line=True,
                                   scrollable=True,
                                   text="")
        self.FrameTable.pack(self.IdentityEntry, 5, 1, 1, 1)
        self.IdentityEntry.show()

        self.FoundationLabel = Label(self.FrameTable,
                                     size_hint_weight=(0.0, 0.0),
                                     size_hint_align=(0.0, 0.5),
                                     text="Foundation:")
        self.FrameTable.pack(self.FoundationLabel, 0, 2, 1, 1)
        self.FoundationLabel.show()

        self.FoundationEntry = Entry(self.FrameTable,
                                     size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                     size_hint_align=(EVAS_HINT_FILL, 0.5),
                                     single_line=True,
                                     scrollable=True,
                                     text="")
        self.FrameTable.pack(self.FoundationEntry, 1, 2, 1, 1)
        self.FoundationEntry.show()

        self.ElementLabel = Label(self.FrameTable,
                                  size_hint_weight=(0.0, 0.0),
                                  size_hint_align=(0.0, 0.5),
                                  text="Element:")
        self.FrameTable.pack(self.ElementLabel, 2, 2, 1, 1)
        self.ElementLabel.show()

        self.ElementEntry = Entry(self.FrameTable,
                                  size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                  size_hint_align=(EVAS_HINT_FILL, 0.5),
                                  single_line=True,
                                  scrollable=True,
                                  text="")
        self.FrameTable.pack(self.ElementEntry, 3, 2, 1, 1)
        self.ElementEntry.show()

        self.DynamoLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Dynamo:")
        self.FrameTable.pack(self.DynamoLabel, 4, 2, 1, 1)
        self.DynamoLabel.show()

        self.DynamoEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.DynamoEntry, 5, 2, 1, 1)
        self.DynamoEntry.show()

        self.ManifoldLabel = Label(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Manifold:")
        self.FrameTable.pack(self.ManifoldLabel, 0, 3, 1, 1)
        self.ManifoldLabel.show()

        self.ManifoldEntry = Entry(self.FrameTable,
                                   size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                   size_hint_align=(EVAS_HINT_FILL, 0.5),
                                   single_line=True,
                                   scrollable=True,
                                   text="")
        self.FrameTable.pack(self.ManifoldEntry, 1, 3, 1, 1)
        self.ManifoldEntry.show()

        self.RingLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Ring:")
        self.FrameTable.pack(self.RingLabel, 2, 3, 1, 1)
        self.RingLabel.show()

        self.RingEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.RingEntry, 3, 3, 1, 1)
        self.RingEntry.show()

        self.BarnLabel = Label(self.FrameTable,
                               size_hint_weight=(0.0, 0.0),
                               size_hint_align=(0.0, 0.5),
                               text="Barn:")
        self.FrameTable.pack(self.BarnLabel, 4, 3, 1, 1)
        self.BarnLabel.show()

        self.BarnEntry = Entry(self.FrameTable,
                               size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                               size_hint_align=(EVAS_HINT_FILL, 0.5),
                               single_line=True,
                               scrollable=True,
                               text="")
        self.FrameTable.pack(self.BarnEntry, 5, 3, 1, 1)
        self.BarnEntry.show()

        self.VoltpereLabel = Label(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Voltpere:")
        self.FrameTable.pack(self.VoltpereLabel, 0, 4, 1, 1)
        self.VoltpereLabel.show()

        self.VoltpereEntry = Entry(self.FrameTable,
                                   size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                   size_hint_align=(EVAS_HINT_FILL, 0.5),
                                   single_line=True,
                                   scrollable=True,
                                   text="")
        self.FrameTable.pack(self.VoltpereEntry, 1, 4, 5, 1)
        self.VoltpereEntry.show()

        self.AmpereLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Ampere:")
        self.FrameTable.pack(self.AmpereLabel, 0, 5, 1, 1)
        self.AmpereLabel.show()

        self.AmpereEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.AmpereEntry, 1, 5, 2, 1)
        self.AmpereEntry.show()

        self.HenryLabel = Label(self.FrameTable,
                                size_hint_weight=(0.0, 0.0),
                                size_hint_align=(0.0, 0.5),
                                text="Henry:")
        self.FrameTable.pack(self.HenryLabel, 0, 6, 1, 1)
        self.HenryLabel.show()

        self.HenryEntry = Entry(self.FrameTable,
                                size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                size_hint_align=(EVAS_HINT_FILL, 0.5),
                                single_line=True,
                                scrollable=True,
                                text="")
        self.FrameTable.pack(self.HenryEntry, 1, 6, 2, 1)
        self.HenryEntry.show()

        self.MaxwellLabel = Label(self.FrameTable,
                                  size_hint_weight=(0.0, 0.0),
                                  size_hint_align=(0.0, 0.5),
                                  text="Maxwell:")
        self.FrameTable.pack(self.MaxwellLabel, 0, 7, 1, 1)
        self.MaxwellLabel.show()

        self.MaxwellEntry = Entry(self.FrameTable,
                                  size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                  size_hint_align=(EVAS_HINT_FILL, 0.5),
                                  single_line=True,
                                  scrollable=True,
                                  text="")
        self.FrameTable.pack(self.MaxwellEntry, 1, 7, 2, 1)
        self.MaxwellEntry.show()

        self.FermatLabel = Label(self.FrameTable,
                                 size_hint_weight=(0.0, 0.0),
                                 size_hint_align=(0.0, 0.5),
                                 text="Fermat:")
        self.FrameTable.pack(self.FermatLabel, 0, 8, 1, 1)
        self.FermatLabel.show()

        self.FermatEntry = Entry(self.FrameTable,
                                 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                                 size_hint_align=(EVAS_HINT_FILL, 0.5),
                                 single_line=True,
                                 scrollable=True,
                                 text="")
        self.FrameTable.pack(self.FermatEntry, 1, 8, 2, 1)
        self.FermatEntry.show()

        self.PropelButton = Button(self.FrameTable,
                                   size_hint_weight=(0.0, 0.0),
                                   size_hint_align=(0.0, 0.5),
                                   text="Propel")
        self.FrameTable.pack(self.PropelButton, 4, 8, 1, 1)
        self.PropelButton.show()
        self.PropelButton.callback_clicked_add(self.propelClicked)