2010-01-26 4 views
7

저는 음악 플레이어를 python으로 작성하고 uriid를 사용하여 cli를 작성합니다. 목록 상자, 열, 더미 및 마지막으로 프레임으로 래핑 된 simpleListWalker에서 현재 재생 목록을 만들려고합니다.현재 표시된 목록 상자의 내용을 urwid/python2.6으로 변경합니다.

이 목록 상자 (또는 simpleListWalker)의 전체 내용을 다른 것으로 바꾸려면 어떻게해야합니까?

관련 코드 :에서

class mainDisplay(object): 
... 
    def renderList(self): 
     songList = db.getListOfSongs() 
     songDictList = [item for item in songList if item['location'] in 
     commandSh.currentPlaylists[commandSh.plyr.currentList]] 
     self.currentSongWidgets = self.createList(songDictList) 
     self.mainListContent = urwid.SimpleListWalker([urwid.AttrMap(w, None, 
     'reveal focus') for w in self.currentSongWidgets]) 
    def initFace(self):#this is the init function that creates the interface 
     #on startup 
     ... 
     self.scanPlaylists() 
     self.renderList() 
     self.mainList = urwid.ListBox(self.mainListContent) 
     self.columns = urwid.Columns([self.mainList, self.secondaryList]) 
     self.pile = urwid.Pile([self.columns, 
     ("fixed", 1, self.statusDisplayOne), 
     ("fixed", 1, self.statusDisplayTwo), 
     ("fixed", 1, self.cmdShInterface)], 3) 
     self.topFrame = urwid.Frame(self.pile) 

전체 코드 : http://github.com/ripdog/PyPlayer/tree/cli는 - 인터페이스 코드 main.py를 확인합니다.

코드가 현재 매우 나쁘고 2 개월 동안 프로그래밍 만했습니다. 코드 스타일, 레이아웃 또는 다른 팁에 대한 제안 사항은 대단히 감사하겠습니다.

답변

4
self.mainListContent[:] = [new, list, of, widgets] 

은 장소에서 위젯의 전체 목록을 대체해야합니다.

빠른 응답을 원하시면 다음 번에 귀하의 질문을 메일 링리스트 또는 IRC 채널에 게시하십시오!

+1

문서에서이 기능을 사용하는 것이 좋습니다. – SummerBreeze

관련 문제