小编Rip*_*dog的帖子

更改urwid/python2.6中当前显示的列表框的内容

我正在用python写一个音乐播放器,用cli使用urwid.我打算将当前播放列表放在一个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)
Run Code Online (Sandbox Code Playgroud)

完整代码:http://github.com/ripdog/PyPlayer/tree/cli - 检查main.py是否有接口代码.

代码目前处于非常糟糕的状态,我只编程了两个月.我们非常感谢您对代码风格,布局或任何其他提示的任何建议.

python urwid

7
推荐指数
1
解决办法
2565
查看次数

使用time_t编写显示当天的函数?

我一直在编写一个时间转换器来获取系统time_t并将其转换为人类可读的日期/时间.哦,这是我的第二个python脚本.我们将这个事实放在一边继续前进.

完整脚本在此处托管.

编写转换器的年份和月份相当容易,但我已经碰到了一个严重的砖墙试图让这一天工作.正如你所看到的那样,从1970年到今天,我一直在努力蛮力.不幸的是,这一天是-105.

有没有人知道更好的方法,或者解决我在这里尝试的方法?现在是凌晨3:30,所以很可能我错过了一些明显的东西.

对不起,我忘了注意我正在手动执行此操作以学习python.不幸的是,通过日期函数执行此操作会失败.

python time time-t

1
推荐指数
1
解决办法
2569
查看次数

标签 统计

python ×2

time ×1

time-t ×1

urwid ×1