sortlistctrl.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:fritzchecksum 作者: mementum 项目源码 文件源码
def DoSort(self, column, status=None):
        '''Separated from event management to allow it to be used internally and
        externally

        When called a list of column text is gathered on the fly to use it
        during the sorting process.

        This is key to avoid the user keeping external data sync'ed: the data
        is already in the control

        Does additional column count control and allows reordering with current
        state

        The rest from the original

        '''

        colcount = self.GetColumnCount()
        if not colcount:
            return
        if column < 0:
            column = 0
        elif column >= colcount:
            column = colcount - 1

        oldcol = self.col  # reference to last sorted column
        self.col = col = column

        if status is None:
            # invert the last sorting order
            self.sortflags[col] = not self.sortflags[col]
        else:
            self.sortflags[col] = status

        self.sortdata = dict()  # prepare the data holder
        for index in xrange(0, self.GetItemCount()):
            # loop over all items and gather the ItemData and ColumnText
            itemdata = self.GetItemData(index)
            item = self.GetItem(index, col)
            self.sortdata[itemdata] = item.GetText()

        self.SortItems(self.GetColumnSorter())  # Sort
        macusegeneric = "mac.listctrl.always_use_generic"
        if wx.Platform != "__WXMAC__" or \
           wx.SystemOptions.GetOptionInt(macusegeneric) == 1:
            # If needed an possible update the images
            self.UpdateImages(oldcol)

        self.OnSortOrderChanged()  # go to the notification callback
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号