def SyncList(self): self._MyList = [] start_x = 0 start_y = 0 if myvars.Poller == None: return play_list = myvars.Poller.playlist() for i, v in enumerate(play_list): li = ListItem() li._Parent = self li._PosX = start_x li._PosY = start_y + i * ListItem._Height li._Width = Width li._Fonts["normal"] = self._ListFont if "title" in v: if isinstance(v["title"], (list, )): li.Init(" | ".join(v["title"])) else: li.Init(v["title"]) if "file" in v: li._Path = v["file"] elif "file" in v: li.Init(os.path.basename(v["file"])) li._Path = v["file"] else: li.Init("NoName") li._Labels["Text"]._PosX = 7 self._MyList.append(li) self.SyncPlaying()
def SyncList(self, path): if myvars.Poller == None: return alist = myvars.Poller.listfiles(path) if alist == False: print("listfiles return false") return self._MyList = [] self._SwapMyList = [] start_x = 0 start_y = 0 hasparent = 0 if self._MyStack.Length() > 0: hasparent = 1 li = ListItem() li._Parent = self li._PosX = start_x li._PosY = start_y li._Width = Width li._Fonts["normal"] = self._ListFont li._MyType = ICON_TYPES["DIR"] li._Parent = self li.Init("[..]") self._MyList.append(li) for i, v in enumerate(sorted(alist)): li = ListItem() li._Parent = self li._PosX = start_x li._PosY = start_y + (i + hasparent) * ListItem._Height li._Width = Width li._Fonts["normal"] = self._ListFont li._MyType = ICON_TYPES["FILE"] li._Parent = self if "directory" in v: li._MyType = ICON_TYPES["DIR"] dir_base_name = os.path.basename(v["directory"]) li.Init(dir_base_name) li._Path = v["directory"] elif "file" in v: bname = os.path.basename(v["file"]) li.Init(bname) li._Path = v["file"] else: li.Init("NoName") self._MyList.append(li) for i in self._MyList: self._SwapMyList.append(i)
def SyncList(self,path): alist = self.buildDirectoryList(path) if not alist: print("buildDirectoryList empty") return self._MyList = [] self._SwapMyList = [] start_x = 0 start_y = 0 hasparent = 0 if self._MyStack.Length() > 0: hasparent = 1 li = ListItem() li._Parent = self li._PosX = start_x li._PosY = start_y li._Width = Width li._Fonts["normal"] = self._ListFont li._MyType = ICON_TYPES["DIR"] li.Init("[..]") self._MyList.append(li) for i,v in enumerate(sorted(alist)): li = ListItem() li._Parent = self li._PosX = start_x li._PosY = start_y + (i+hasparent)*ListItem._Height li._Width = Width li._Fonts["normal"] = self._ListFont li._MyType = ICON_TYPES["FILE"] if not v['is_file']: li._MyType = ICON_TYPES["DIR"] else: li._MyType = ICON_TYPES["FILE"] li.Init( v['name'] ) li._Path = v["file_path"] self._MyList.append(li) for i in self._MyList: self._SwapMyList.append(i)