Changing the contents of the currently displayed list in urwid / python2.6

I am writing a music player in python, with a Kli using urwid. I intend to have the current playlist in simpleListWalker wrapped in a list, then columns, a bunch, and finally a frame.

How to replace all contents of this list (or simpleListWalker) with something else?

Relevant Code:

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) 

Full code: http://github.com/ripdog/PyPlayer/tree/cli - Check the main.py file for the interface code.

The code is currently in pretty bad shape, and I only programmed for two months. Any suggestions for code style, layout, or any other tips you may have are greatly appreciated.

+7
python urwid
source share
1 answer
 self.mainListContent[:] = [new, list, of, widgets] 

should replace the entire list of widgets in place.

Next time send your question to the mailing list or IRC if you want a quicker answer!

+4
source share

All Articles