Ejemplo n.º 1
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)
Ejemplo n.º 2
0
Archivo: gui.py Proyecto: simotek/egitu
    def __init__(self, win, url=None):
        Popup.__init__(self, win)
        self.win = win

        # title
        self.part_text_set('title,text', 'Recent Repositories')
        ic = Icon(self, file=theme_resource_get('egitu.png'))
        self.part_content_set('title,icon', ic)

        # content: recent list
        li = List(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        li.callback_activated_add(self.recent_selected_cb)

        recents = recent_history_get()
        if recents:
            for recent_url in recents:
                path, name = os.path.split(recent_url)
                item = li.item_append(name)
                item.data['url'] = recent_url
        else:
            item = li.item_append('no recent repository')
            item.disabled = True
        li.show()

        # table+rect to respect min size :/
        tb = Table(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        r = Rectangle(self.evas, color=(0,0,0,0), size_hint_min=(200,200),
                      size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        tb.pack(r, 0, 0, 1, 1)
        tb.pack(li, 0, 0, 1, 1)
        self.content = tb

        # popup auto-list - not expand well :(
        # self.size_hint_weight = EXPAND_BOTH
        # self.size_hint_align = FILL_BOTH
        # self.size_hint_min = 400, 400
        # self.item_append('no recent repos', None)
        # self.item_append('asd2', None)
        # self.item_append('asd2', None)

        # buttons
        bt = Button(self, text='Open')
        bt.callback_clicked_add(self.load_btn_cb)
        self.part_content_set('button1', bt)

        bt = Button(self, text='Clone (TODO)')
        bt.disabled = True
        self.part_content_set('button2', bt)

        bt = Button(self, text='Create (TODO)')
        bt.disabled = True
        self.part_content_set('button3', bt)

        if url is not None:
            self.try_to_load(url)
        else:
            self.callback_block_clicked_add(lambda p: p.delete())
            self.show()
Ejemplo n.º 3
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
            assert isinstance(title, basestring)
            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.pack(btn, count, 0, 1, 1)
            self.header_row.append(btn)
def calendar_clicked(obj, item=None):
    win = StandardWindow("calendar", "Calendar", autodel=True)

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

    bt = Button(bx, text="Next API function")
    bt.callback_clicked_add(api_bt_clicked, api)
    bx.pack_end(bt)
    if api["state"] == API_STATE_LAST:
        bt.disabled = True
    bt.show()

    the_time = datetime(2010, 12, 31)
    cal = Calendar(bx,
                   first_day_of_week=ELM_DAY_MONDAY,
                   size_hint_weight=EXPAND_BOTH,
                   selected_time=the_time,
                   min_max_year=(2010, 2012))
    api["cal"] = cal
    bx.pack_end(cal)
    cal.show()

    win.show()
Ejemplo n.º 5
0
def grid_clicked(obj):
    win = StandardWindow("grid", "Grid test", autodel=True, size=(480, 480))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    gd = Grid(win, size=(100, 100), size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(gd)
    gd.show()

    en = Entry(win, scrollable=True, text="Entry text 2", single_line=True)
    gd.pack(en, 60, 20, 30, 10)
    en.show()

    bt = Button(win, text="Next API function", disabled=True)
    gd.pack(bt, 30, 0, 40, 10)
    bt.disabled = True
    bt.show()

    bt = Button(win, text="Button")
    gd.pack(bt, 0, 0, 20, 20)
    bt.show()

    bt = Button(win, text="Button")
    gd.pack(bt, 10, 10, 40, 20)
    bt.show()

    bt = Button(win, text="Button")
    gd.pack(bt, 10, 30, 20, 50)
    bt.show()

    bt = Button(win, text="Button")
    gd.pack(bt, 80, 80, 20, 20)
    bt.show()

    bt = Button(win, text="Change")
    bt.callback_clicked_add(cb_change)
    gd.pack(bt, 40, 40, 20, 20)
    bt.show()

    re = Rectangle(win.evas, color=(128, 0, 0, 128))
    gd.pack(re, 40, 70, 20, 10)
    re.show()

    re = Rectangle(win.evas, color=(0, 128, 0, 128))
    gd.pack(re, 60, 70, 10, 10)
    re.show()

    re = Rectangle(win.evas, color=(0, 0, 128, 128))
    gd.pack(re, 40, 80, 10, 10)
    re.show()

    re = Rectangle(win.evas, color=(128, 0, 128, 128))
    gd.pack(re, 50, 80, 10, 10)
    re.show()

    re = Rectangle(win.evas, color=(128, 64, 0, 128))
    gd.pack(re, 60, 80, 10, 10)
    re.show()

    win.show()
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
    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 calendar_clicked(obj, item=None):
    win = StandardWindow("calendar", "Calendar", autodel=True)

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

    bt = Button(bx, text="Next API function")
    bt.callback_clicked_add(api_bt_clicked, api)
    bx.pack_end(bt)
    if api["state"] == API_STATE_LAST:
        bt.disabled = True
    bt.show()

    the_time = datetime(2010, 12, 31)
    cal = Calendar(bx, first_day_of_week=ELM_DAY_MONDAY,
        size_hint_weight=EXPAND_BOTH, selected_time=the_time,
        min_max_year=(2010,2012))
    api["cal"] = cal
    bx.pack_end(cal)
    cal.show()

    win.show()
Ejemplo n.º 10
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
            assert isinstance(title, basestring)
            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
            if count == 0:
                btn = Button(self,
                             size_hint_weight=(0.0, 1.0),
                             size_hint_align=(0.0, 0.5),
                             text=title)
            else:
                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.pack(btn, count, 0, 1, 1)
            self.header_row.append(btn)
Ejemplo n.º 11
0
    def header_row_pack(self, titles):
        """Takes a list (or a tuple) of tuples (string, bool, int) 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)

        titleCount = len(titles)
        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_row.append(btn)

            bx = Box(self,
                     size_hint_weight=EXPAND_BOTH,
                     size_hint_align=FILL_BOTH)
            bx.show()

            if len(self.listPanes) < titleCount:
                wdth = 1.0 / (titleCount - count)
                self.listPanes[count].part_content_set("left", bx)
                self.listPanes[count].content_left_size = wdth

                nextList = Panes(self,
                                 size_hint_weight=EXPAND_BOTH,
                                 size_hint_align=FILL_BOTH)
                nextList.callback_unpress_add(self.paneResized)
                nextList.style_set("flush")
                nextList.show()

                self.listPanes[count].part_content_set("right", nextList)
                self.listPanes.append(nextList)

                self.headerPanes[count].part_content_set("left", btn)
                self.headerPanes[count].content_left_size = wdth

                nextHeader = Panes(self,
                                   size_hint_weight=EXPAND_HORIZ,
                                   size_hint_align=FILL_HORIZ)
                nextHeader.callback_unpress_add(self.paneResized)
                nextHeader.show()

                self.headerPanes[count].part_content_set("right", nextHeader)
                self.headerPanes.append(nextHeader)

                nextList.data["related"] = nextHeader
                nextHeader.data["related"] = nextList
            else:
                self.listPanes[count - 1].part_content_set("right", bx)
                self.headerPanes[count - 1].part_content_set("right", btn)

            self.lists.append(bx)
Ejemplo n.º 12
0
    def header_row_pack(self, titles):

        """Takes a list (or a tuple) of tuples (string, bool, int) 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)

        titleCount = len(titles)
        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_row.append(btn)
            
            bx = Box(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
            bx.show()
            
            if len(self.listPanes) < titleCount:
                wdth = 1.0 / (titleCount - count)
                self.listPanes[count].part_content_set("left", bx)
                self.listPanes[count].content_left_size = wdth
                
                nextList = Panes(self, size_hint_weight=EXPAND_BOTH,
                        size_hint_align=FILL_BOTH)
                nextList.callback_unpress_add(self.paneResized)
                nextList.style_set("flush")
                nextList.show()
                
                self.listPanes[count].part_content_set("right", nextList)
                self.listPanes.append(nextList)
                
                self.headerPanes[count].part_content_set("left", btn)
                self.headerPanes[count].content_left_size = wdth
                
                nextHeader = Panes(self, size_hint_weight=EXPAND_HORIZ,
                        size_hint_align=FILL_HORIZ)
                nextHeader.callback_unpress_add(self.paneResized)
                nextHeader.show()
                
                self.headerPanes[count].part_content_set("right", nextHeader)
                self.headerPanes.append(nextHeader)
                
                nextList.data["related"] = nextHeader
                nextHeader.data["related"] = nextList
            else:
                self.listPanes[count - 1].part_content_set("right", bx)
                self.headerPanes[count - 1].part_content_set("right", btn)
            
            self.lists.append(bx)
Ejemplo n.º 13
0
    def header_row_pack(self, titles):
        '''Takes a list (or a tuple) of tuples (string, bool, int) 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
            assert isinstance(title, str)
            assert isinstance(sortable, bool)

        def cb_sort_btn(button, col):
            '''Aux function'''
            if self.sort_column == col:
                self.reverse()
            else:
                self.sort_by_column(col)

        title_cnt = len(titles)
        for count, flag in enumerate(titles):
            title, sortable = flag
            btn = Button(self,
                         size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=FILL_HORIZ,
                         text=title)
            btn.callback_clicked_add(cb_sort_btn, count)
            if not sortable:
                btn.disabled = True
            btn.show()
            self.header_row.append(btn)

            box = Box(self,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
            box.show()

            if len(self.list_panes) < title_cnt:
                wdth = 1.0 / (title_cnt - count)
                self.list_panes[count].part_content_set("left", box)
                self.list_panes[count].content_left_size = wdth

                next_list = Panes(self,
                                  size_hint_weight=EXPAND_BOTH,
                                  size_hint_align=FILL_BOTH)
                next_list.callback_unpress_add(self.cb_resize_pane)
                next_list.style_set("flush")
                next_list.show()

                self.list_panes[count].part_content_set("right", next_list)
                self.list_panes.append(next_list)

                self.headers[count].part_content_set("left", btn)
                self.headers[count].content_left_size = wdth

                next_header = Panes(self,
                                    size_hint_weight=EXPAND_HORIZ,
                                    size_hint_align=FILL_HORIZ)
                next_header.callback_unpress_add(self.cb_resize_pane)
                next_header.show()

                self.headers[count].part_content_set("right", next_header)
                self.headers.append(next_header)

                next_list.data["related"] = next_header
                next_header.data["related"] = next_list
            else:
                self.list_panes[count - 1].part_content_set("right", box)
                self.headers[count - 1].part_content_set("right", btn)

            self.lists.append(box)