guis.py 文件源码

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

项目:script.reddit.reader 作者: gedisony 项目源码 文件源码
def __init__(self, *args, **kwargs):
        xbmcgui.WindowXML.__init__(self, *args, **kwargs)
        #xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)   #<--- what's the difference?
        self.subreddits_file = kwargs.get("subreddits_file")
        self.listing = kwargs.get("listing")
        self.main_control_id = kwargs.get("id")

        #self.gui_listbox.addItems(self.listing)

        listing_generator=generator(self.listing)

        tlc_id=0 #create id's for top-level-comments
        self.child_lists[:] = []  #a collection of child comments (non-tlc) tlc_children
        tlc_children=[]
        #for listing in self.listing:
        for listing in listing_generator:
            depth=int(listing.getProperty('comment_depth'))
            #add root comments and links on the listbox
            if not listing.getProperty('link_url'):
                if depth==0:
                    tlc_id+=1
                    listing.setProperty('tlc_id',str(tlc_id)) #assign an id to this top-level-comment
                    self.items_for_listbox.append(listing)    #this post will be on the listbox
                    #log('tlc: '+listing.getProperty('plot'))

                    #save the set of comments from previous top level comment
                    self.child_lists.append(tlc_children)

                    #begin a new list of child comments(this does not clear the old refernces)
                    tlc_children=[]
                    tlc_children.append( self.get_post_text_tuple(listing) ) #save the post_text of the top level comment
                else:
                    #collect the child comments. when depth=0 again, this list is reset.
                    child_comment=listing
                    #log('   : '+child_comment.getProperty('plot'))
                    tlc_children.append( self.get_post_text_tuple(child_comment) )
            else: #link in tlc
                if depth>0:
                    listing.setProperty('tlc_id',str(tlc_id))
                    listing.setProperty('non_tlc_link','true')

                listing.setProperty('tlc_id',str(tlc_id))
                self.items_for_listbox.append(listing)

        #don't forget to add the children of the last tlc
        self.child_lists.append(tlc_children)
        #log(pprint.pformat(self.child_lists))
        self.exit_monitor = ExitMonitor(self.close_gui)#monitors for abortRequested and calls close on the gui

        #can't dynamically create an auto-height textbox inside a grouplist
        #  so we make x of them in the xml and hope they're enough
        #  these are their id's
        self.x_controls=[x for x in range(1000, 1071)]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号