예제 #1
0
    def __init__(self,
                 parent_widget,
                 *args,
                 titles=None,
                 initial_sort=0,
                 ascending=True,
                 **kwargs):
        Scroller.__init__(self, parent_widget, *args, **kwargs)
        self.policy_set(ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF)

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

        self.header = titles
        self.sort_column = initial_sort
        self.sort_column_ascending = ascending

        self.rows = []
        self.header_row = []

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

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

        header.data["related"] = list_pane
        list_pane.data["related"] = header

        self.scroller = Scroller(self,
                                 size_hint_weight=EXPAND_BOTH,
                                 size_hint_align=FILL_BOTH)
        self.scroller.policy_set(ELM_SCROLLER_POLICY_OFF,
                                 ELM_SCROLLER_POLICY_AUTO)
        self.scroller.content = list_pane
        self.scroller.show()

        self.headers = []
        self.headers.append(header)
        self.list_panes = []
        self.list_panes.append(list_pane)
        self.lists = []

        if titles is not None:
            self.header_row_pack(titles)

        self.main_box.pack_end(header)
        self.main_box.pack_end(self.scroller)

        self.content = self.main_box
        self.show()
예제 #2
0
    def __init__(self, parent_widget, titles=None, initial_sort=0,
        ascending=True, *args, **kwargs):
        Scroller.__init__(self, parent_widget, *args, **kwargs)
        self.policy_set(ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF)

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

        self.header = titles
        self.sort_column = initial_sort
        self.sort_column_ascending = ascending

        self.rows = []
        self.header_row = []
        
        headerPane = Panes(self, size_hint_weight=EXPAND_HORIZ,
                size_hint_align=FILL_HORIZ)
        headerPane.callback_unpress_add(self.paneResized)
        headerPane.show()
        
        listPane = Panes(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
        listPane.callback_unpress_add(self.paneResized)
        listPane.style_set("flush")
        listPane.show()
        
        headerPane.data["related"] = listPane
        listPane.data["related"] = headerPane
        
        self.mainScr = Scroller(self, size_hint_weight=EXPAND_BOTH,
                size_hint_align=FILL_BOTH)
        self.mainScr.policy_set(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO)
        self.mainScr.content = listPane
        self.mainScr.show()
        
        self.headerPanes  = []
        self.headerPanes.append(headerPane)
        self.listPanes = []
        self.listPanes.append(listPane)
        self.lists = []

        #self.pack_end(self.header_box)

        if titles is not None:
            self.header_row_pack(titles)
            
        self.mainBox.pack_end(headerPane)
        self.mainBox.pack_end(self.mainScr)
        
        self.content = self.mainBox
        self.show()
예제 #3
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)
예제 #4
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)
예제 #5
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)