fb.py 文件源码

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

项目:plotcommander 作者: FilipDominec 项目源码 文件源码
def populateFileSystemTreeStore(treeStore, path, parent=None):
    itemCounter = 0
    for item in os.listdir(path):                           # iterate over the items in the path
        itemFullname = os.path.join(path, item)             # Get the absolute path of the item
        itemMetaData = os.stat(itemFullname)                # Extract metadata from the item
        itemIsFolder = stat.S_ISDIR(itemMetaData.st_mode)   # Determine if the item is a folder
        itemIcon = Gtk.IconTheme.get_default().load_icon("folder" if itemIsFolder else "empty", 8, 0) # Generate a default icon
        currentIter = treeStore.append(parent, [item, itemIcon, itemFullname])      # Append the item to the TreeStore
        if itemIsFolder: treeStore.append(currentIter, [None, None, None])      # add dummy if current item was a folder
        itemCounter += 1                                    #increment the item counter
    if itemCounter < 1: treeStore.append(parent, [None, None, None])        # add the dummy node back if nothing was inserted before
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号