当前位置: 首页>>代码示例>>Python>>正文


Python Model.updateModel方法代码示例

本文整理汇总了Python中Model.Model.updateModel方法的典型用法代码示例。如果您正苦于以下问题:Python Model.updateModel方法的具体用法?Python Model.updateModel怎么用?Python Model.updateModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model.Model的用法示例。


在下文中一共展示了Model.updateModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GUI

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import updateModel [as 别名]

#.........这里部分代码省略.........
            else:
                return []
        except:
            return []

    def __expFunc(self, tree, path):
        """Stores the currently expanded rows"""
        model = tree.get_model()
        iter = model.get_iter(path)
        folderName = model.get_value(iter, 0)
        self.expandedList.append(folderName)

    def __restoreExpanded(self, model, path, iter):
        """Re-expands the previously expanded rows (to use after a treeView refresh)"""
        iter = model.get_iter(path)
        folderName = model.get_value(iter, 0)
        if folderName in self.expandedList:
            self.view.filesTree.treeview.expand_row(path, False)

    def __refreshViewTree(self):
        """Refreshes the treeview"""
        self.expandedList = []
        self.view.filesTree.treeview.map_expanded_rows(self.__expFunc)
        self.view.filesTree.setModel(self.model)
        self.view.filesTree.searchBox.setListStore(self.view.filesTree.listStore)
        self.view.filesTree.treeStore.foreach(self.__restoreExpanded)

    def refreshTree(self, widget = None, data = None, update = True):
        """Refreshes the Model and the file browser treeView"""
        self.view.vbox.pack_start(self.view.progressBar, False)
        #self.view.progressBar.pulse()
        self.view.statusbar.push(0, 'Updating library...')
        gtkTrick()
        if update: self.model.updateModel()
        if self.model.changed:
            self.__refreshViewTree()
            if self.settings['libraryMode']:
                self.saveLibrary()
            else:
                self.saveCache()
        self.view.statusbar.pop(0)
        self.view.vbox.remove(self.view.progressBar)

    def toggle(self, cell, path, rowModel):
        """Adds the selected files to the playlist and updates the treeview"""
        print
        row = rowModel[path]
        self.__addTrack(row)
        if type(rowModel).__name__ == 'TreeStore':
            self.__recursiveToggle(path, rowModel)
        self.updatePlaylist()

    def __recursiveToggle(self, path, rowModel):
        """Recursively adds the selected files to the playlist and updates the treeview"""
        i=0
        rowexists = True
        while True:
            try:
                row = rowModel[path + (":%d" % (i))]
                self.__addTrack(row)
                self.__recursiveToggle((path + (":%d" % (i))), rowModel)
                i+=1
            except:
                rowexists = False
                #print sys.exc_info()
            if not rowexists:
开发者ID:andrebask,项目名称:cometsound,代码行数:70,代码来源:Controller.py


注:本文中的Model.Model.updateModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。