Esempio n. 1
0
    def __init__(self, parent, width=None, height=None, group=None):
        InnerWindow.__init__(self, parent)

        self._parent = parent
        #self.style_set("minimal")  # size fallbacks to __layout's min/max

        box = Box(self)
        box.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
        box.show()

        content = Box(self)
        content.size_hint_weight_set(evas.EVAS_HINT_EXPAND,
                                     evas.EVAS_HINT_EXPAND)
        content.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
        box.pack_end(content)
        content.show()

        actions = Box(self)
        actions.horizontal_set(True)
        box.pack_end(actions)
        actions.show()

        btn = WizardAction(self._parent, "Close", self.close, "Escape", None)
        btn.show()
        actions.pack_end(btn)

        layout = Layout(self)
        self.__edje = layout.edje_get()
        theme_file = sysconfig.theme_file_get("default")
        _width = width or self.default_width
        _height = height or self.default_height
        _group = group or self.default_group
        layout.file_set(theme_file, _group)
        layout.size_hint_min_set(_width, _height)
        layout.size_hint_max_set(_width, _height)

        InnerWindow.content_set(self, layout)
        layout.show()
        layout.content_set("content", box)

        self.__sc = Entry(self)
        self.__sc.scrollable_set(True)
        self.__sc.editable_set(False)
        self.__sc.size_hint_weight_set(evas.EVAS_HINT_EXPAND,
                                evas.EVAS_HINT_EXPAND)
        self.__sc.size_hint_align_set(evas.EVAS_HINT_FILL,
                               evas.EVAS_HINT_FILL)
        self.__sc.bounce_set(False, False)
        self.__sc.show()
        content.pack_end(self.__sc)
Esempio n. 2
0
    def __init__(self, parent, width=None, height=None, group=None):
        InnerWindow.__init__(self, parent)

        self._parent = parent
        #self.style_set("minimal")  # size fallbacks to __layout's min/max

        box = Box(self)
        box.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
        box.show()

        content = Box(self)
        content.size_hint_weight_set(evas.EVAS_HINT_EXPAND,
                                     evas.EVAS_HINT_EXPAND)
        content.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
        box.pack_end(content)
        content.show()

        actions = Box(self)
        actions.horizontal_set(True)
        box.pack_end(actions)
        actions.show()

        btn = WizardAction(self._parent, "Close", self.close, "Escape", None)
        btn.show()
        actions.pack_end(btn)

        layout = Layout(self)
        self.__edje = layout.edje_get()
        theme_file = sysconfig.theme_file_get("default")
        _width = width or self.default_width
        _height = height or self.default_height
        _group = group or self.default_group
        layout.file_set(theme_file, _group)
        layout.size_hint_min_set(_width, _height)
        layout.size_hint_max_set(_width, _height)

        InnerWindow.content_set(self, layout)
        layout.show()
        layout.content_set("content", box)

        self.__sc = Entry(self)
        self.__sc.scrollable_set(True)
        self.__sc.editable_set(False)
        self.__sc.size_hint_weight_set(evas.EVAS_HINT_EXPAND,
                                       evas.EVAS_HINT_EXPAND)
        self.__sc.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
        self.__sc.bounce_set(False, False)
        self.__sc.show()
        content.pack_end(self.__sc)
Esempio n. 3
0
class Wizard(InnerWindow):
    default_width = 500
    default_height = 500
    default_group = "editje/wizard"

    def __init__(self, parent, width=None, height=None, group=None):
        InnerWindow.__init__(self, parent)

        self._parent = parent
        #self.style_set("minimal")  # size fallbacks to __layout's min/max

        self.__layout = Layout(self)
        self.__edje = self.__layout.edje_get()
        self.__theme_file = sysconfig.theme_file_get("default")
        self.__width = width or self.default_width
        self.__height = height or self.default_height
        _group = group or self.default_group
        self.__layout.file_set(self.__theme_file, _group)
        self.__layout.size_hint_min_set(self.__width, self.__height)
        self.__layout.size_hint_max_set(self.__width, self.__height)

        self.on_key_down_add(self.__key_down_cb)

        InnerWindow.content_set(self, self.__layout)
        self.__layout.show()

        self.__pager = Naviframe(self)
        self.__pager.style_set("editje.rightwards")
        self.__pager.show()
        self.__layout.content_set("content", self.__pager)

        self.__pages = {}
        self.__current_page = None
        self.__notification = None

    def _subtitle_text_set(self, value):
        if not value:
            self.__edje.signal_emit("wizard,subtitle,hide", "")
            self.__edje.part_text_set("subtitle.text", "")
        else:
            self.__edje.signal_emit("wizard,subtitle,show", "")
            self.__edje.part_text_set("subtitle.text", value)

    subtitle_text = property(fset=_subtitle_text_set)

    def alternate_background_set(self, value):
        if value:
            self.__edje.signal_emit("wizard,bg,alternate", "")
        else:
            self.__edje.signal_emit("wizard,bg,default", "")

    def _title_text_set(self, value):
        if not value:
            self.__edje.part_text_set("title.text", "")
        else:
            self.__edje.part_text_set("title.text", value)

    title_text = property(fset=_title_text_set)

    def page_add(self, name, title="", subtitle="", separator=False):
        box = Box(self)
        box.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
        box.show()

        content = Box(self)
        content.size_hint_weight_set(evas.EVAS_HINT_EXPAND,
                                     evas.EVAS_HINT_EXPAND)
        content.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
        box.pack_end(content)
        content.show()

        if separator:
            sp = Separator(self)
            sp.horizontal_set(True)
            box.pack_end(sp)
            sp.show()

        actions = Box(self)
        actions.horizontal_set(True)
        box.pack_end(actions)
        actions.show()

        self.__pages[name] = (title, subtitle, box, content, actions, {})
        self.title_text = title
        self.subtitle_text = subtitle
        self.__pager.item_simple_push(box)
        self.__current_page = name

    def content_add(self, pg_name, c):
        page = self.__pages.get(pg_name)
        if page:
            title, subtitle, box, content, actions, action_btns = page
            content.pack_end(c)

    # TODO: add support for equal-named actions on a page, if needed
    def action_add(self, pg_name, label, func_cb, data=None, icon=None,
                   key=None):
        page = self.__pages.get(pg_name)
        if page:
            title, subtitle, box, content, actions, action_btns = page

            btn = WizardAction(self._parent, label, func_cb, key, data)

            if icon:
                ico = Icon(self._parent)
                ico.file_set(self.__theme_file, "editje/icon/" + icon)
                btn.content_set(ico)
                ico.show()

            action_btns[label] = btn

            btn.show()
            actions.pack_end(btn)

    def action_disabled_set(self, pg_name, label, disabled):
        page = self.__pages.get(pg_name)
        if page:
            title, subtitle, box, content, actions, action_btns = page
            action_btns[label].disabled_set(disabled)

    def goto(self, page_name):
        page = self.__pages.get(page_name)
        if page:
            title, subtitle, box, content, actions, action_btns = page
            self.title_text = title
            self.subtitle_text = subtitle
            self.__pager.item_simple_promote(box)
            self.__current_page = page_name

    def notify(self, message):
        if self.__notification:
            self.__notification.hide()
            self.__notification.delete()
            self.__notification = None
        self.__notification = Notify(self)
        self.__notification.timeout_set(2)
        self.__notification.orient_set(ELM_NOTIFY_ORIENT_TOP)

        bx = Box(self)
        bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
        bx.horizontal_set(True)
        self.__notification.content_set(bx)
        bx.show()

        lb = Label(self)
        lb.text_set(message)
        bx.pack_end(lb)
        lb.show()

        self.__notification.show()

    def show(self):
        global _instance
        if _instance:
            _instance.hide()
        _instance = self

        # only Wizard InnerWindows are to be on top of the window blocker
        self._parent.block(True, self)
        InnerWindow.show(self)
        self.focus_set(True)

    def hide(self):
        global _instance
        if _instance == self:
            _instance = None
        InnerWindow.hide(self)
        self._parent.block(False)

    def open(self):
        self.show()

    def close(self):
        self._parent.focus_set(True)
        self.hide()
        self.delete()

    def __key_down_cb(self, obj, event):
        page = self.__pages.get(self.__current_page)
        if not page:
            return
        acts = page[-1]
        for a in acts.itervalues():
            if a.key == event.keyname:
                a()
                return
Esempio n. 4
0
class Wizard(InnerWindow):
    default_width = 500
    default_height = 500
    default_group = "editje/wizard"

    def __init__(self, parent, width=None, height=None, group=None):
        InnerWindow.__init__(self, parent)

        self._parent = parent
        #self.style_set("minimal")  # size fallbacks to __layout's min/max

        self.__layout = Layout(self)
        self.__edje = self.__layout.edje_get()
        self.__theme_file = sysconfig.theme_file_get("default")
        self.__width = width or self.default_width
        self.__height = height or self.default_height
        _group = group or self.default_group
        self.__layout.file_set(self.__theme_file, _group)
        self.__layout.size_hint_min_set(self.__width, self.__height)
        self.__layout.size_hint_max_set(self.__width, self.__height)

        self.on_key_down_add(self.__key_down_cb)

        InnerWindow.content_set(self, self.__layout)
        self.__layout.show()

        self.__pager = Naviframe(self)
        self.__pager.style_set("editje.rightwards")
        self.__pager.show()
        self.__layout.content_set("content", self.__pager)

        self.__pages = {}
        self.__current_page = None
        self.__notification = None

    def _subtitle_text_set(self, value):
        if not value:
            self.__edje.signal_emit("wizard,subtitle,hide", "")
            self.__edje.part_text_set("subtitle.text", "")
        else:
            self.__edje.signal_emit("wizard,subtitle,show", "")
            self.__edje.part_text_set("subtitle.text", value)

    subtitle_text = property(fset=_subtitle_text_set)

    def alternate_background_set(self, value):
        if value:
            self.__edje.signal_emit("wizard,bg,alternate", "")
        else:
            self.__edje.signal_emit("wizard,bg,default", "")

    def _title_text_set(self, value):
        if not value:
            self.__edje.part_text_set("title.text", "")
        else:
            self.__edje.part_text_set("title.text", value)

    title_text = property(fset=_title_text_set)

    def page_add(self, name, title="", subtitle="", separator=False):
        box = Box(self)
        box.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
        box.show()

        content = Box(self)
        content.size_hint_weight_set(evas.EVAS_HINT_EXPAND,
                                     evas.EVAS_HINT_EXPAND)
        content.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
        box.pack_end(content)
        content.show()

        if separator:
            sp = Separator(self)
            sp.horizontal_set(True)
            box.pack_end(sp)
            sp.show()

        actions = Box(self)
        actions.horizontal_set(True)
        box.pack_end(actions)
        actions.show()

        self.__pages[name] = (title, subtitle, box, content, actions, {})
        self.title_text = title
        self.subtitle_text = subtitle
        self.__pager.item_simple_push(box)
        self.__current_page = name

    def content_add(self, pg_name, c):
        page = self.__pages.get(pg_name)
        if page:
            title, subtitle, box, content, actions, action_btns = page
            content.pack_end(c)

    # TODO: add support for equal-named actions on a page, if needed
    def action_add(self,
                   pg_name,
                   label,
                   func_cb,
                   data=None,
                   icon=None,
                   key=None):
        page = self.__pages.get(pg_name)
        if page:
            title, subtitle, box, content, actions, action_btns = page

            btn = WizardAction(self._parent, label, func_cb, key, data)

            if icon:
                ico = Icon(self._parent)
                ico.file_set(self.__theme_file, "editje/icon/" + icon)
                btn.content_set(ico)
                ico.show()

            action_btns[label] = btn

            btn.show()
            actions.pack_end(btn)

    def action_disabled_set(self, pg_name, label, disabled):
        page = self.__pages.get(pg_name)
        if page:
            title, subtitle, box, content, actions, action_btns = page
            action_btns[label].disabled_set(disabled)

    def goto(self, page_name):
        page = self.__pages.get(page_name)
        if page:
            title, subtitle, box, content, actions, action_btns = page
            self.title_text = title
            self.subtitle_text = subtitle
            self.__pager.item_simple_promote(box)
            self.__current_page = page_name

    def notify(self, message):
        if self.__notification:
            self.__notification.hide()
            self.__notification.delete()
            self.__notification = None
        self.__notification = Notify(self)
        self.__notification.timeout_set(2)
        self.__notification.orient_set(ELM_NOTIFY_ORIENT_TOP)

        bx = Box(self)
        bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
        bx.horizontal_set(True)
        self.__notification.content_set(bx)
        bx.show()

        lb = Label(self)
        lb.text_set(message)
        bx.pack_end(lb)
        lb.show()

        self.__notification.show()

    def show(self):
        global _instance
        if _instance:
            _instance.hide()
        _instance = self

        # only Wizard InnerWindows are to be on top of the window blocker
        self._parent.block(True, self)
        InnerWindow.show(self)
        self.focus_set(True)

    def hide(self):
        global _instance
        if _instance == self:
            _instance = None
        InnerWindow.hide(self)
        self._parent.block(False)

    def open(self):
        self.show()

    def close(self):
        self._parent.focus_set(True)
        self.hide()
        self.delete()

    def __key_down_cb(self, obj, event):
        page = self.__pages.get(self.__current_page)
        if not page:
            return
        acts = page[-1]
        for a in acts.itervalues():
            if a.key == event.keyname:
                a()
                return