urwid を使用する cli を使用して、python で音楽プレーヤーを作成しています。リストボックス、列、パイル、最後にフレームでラップされた、現在のプレイリストを simpleListWalker に入れるつもりです。
このリストボックス (または 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 か月しか経っていません。コード スタイル、レイアウト、またはその他のヒントに関する提案は、非常に高く評価されます。