当前位置: 首页>>代码示例>>Python>>正文


Python UI.status方法代码示例

本文整理汇总了Python中ui.UI.status方法的典型用法代码示例。如果您正苦于以下问题:Python UI.status方法的具体用法?Python UI.status怎么用?Python UI.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ui.UI的用法示例。


在下文中一共展示了UI.status方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from ui import UI [as 别名]
# 或者: from ui.UI import status [as 别名]
class Downloader:
    def __init__(self):
        self.path = DOWNLOAD_PATH
        self.ui = UI()
        if not os.path.exists(self.path):
            os.mkdir(self.path)

    def download(self, song):
        url = song['source']
        filename = song['name'] + ' - ' + song['artist'] + '.mp3'
        path = os.path.join(self.path, filename)
        try:
            self.ui.status(filename, 'Downloading')
            if not os.path.exists(path):
                def download_thread(url, path):
                    urllib.urlretrieve(url , path)
                    self.ui.status(filename, 'Finish Download', 5)
                thread = threading.Thread(target=download_thread, args=(url, path))
                thread.start()
            else:
                self.ui.status(filename, 'Exists Download', 4)
        except:
            self.ui.status(filename, 'Error Download', 3)
开发者ID:MashiMaroLjc,项目名称:Nada,代码行数:25,代码来源:downloader.py

示例2: __init__

# 需要导入模块: from ui import UI [as 别名]
# 或者: from ui.UI import status [as 别名]

#.........这里部分代码省略.........
                if view == 'songs':
                    self.index = self.player.play_id % length
                    if idx == offset:
                        if offset == 0:
                            continue
                        self.offset -= step
                time.sleep(0.1)

            elif key == ord('p'):
                if len(self.present) == 0:
                    continue
                self.stack.append([self.title, self.model, self.view, self.ctrl, self.offset, self.index])

                self.title = self.present[0]
                self.model = self.present[1]
                self.view = self.present[2]
                self.ctrl = self.present[3]
                self.index = idx = self.player.play_id
                self.offset = idx // step * step

            elif key == ord('m'):
                if view != 'menu':
                    self.stack.append([self.title, self.model, self.view, self.ctrl, self.offset, self.index])

                    self.title = self.stack[0][0]
                    self.model = self.stack[0][1]
                    self.view = self.stack[0][2]
                    self.ctrl = self.stack[0][3]
                    self.offset = self.stack[0][4]
                    self.index = self.stack[0][5]

            elif key == ord('a'):
                if view == 'songs' and ctrl is not 'collections':
                    self.ui.status(model['songs'][idx]['name'], 'Add', 5)
                    self.collections.append(model['songs'][idx])

            elif key == ord('r'):
                if ctrl == 'collections':
                    if length != 0:
                        self.ui.status(model['songs'][idx]['name'], 'Remove', 3)
                        self.model['songs'].pop(idx)
                        self.index = carousel(offset, min(length, offset + step) - 1, idx)

            elif key == ord('c'):
                self.stack.append([self.title, self.model, self.view, self.ctrl, self.offset, self.index])
                self.title = 'Nada > nada 收藏'
                self.collection()

            elif key == ord('d'):
                if view == 'songs':
                    self.downloader.download(model['songs'][idx])

            self.play_vol = self.player.play_vol
            self.play_id = self.player.play_id
            self.ui.build(self.title, self.model, self.view, self.offset, self.index, self.step, self.play_vol,
                          self.play_id)
            self.ui.screen.refresh()

        self.player.stop()
        self.database.save()
        curses.endwin()

    def control(self, idx):
        self.stack.append([self.title, self.model, self.view, self.ctrl, self.offset, self.index])

        ctrl = self.ctrl
开发者ID:ahonn,项目名称:nada,代码行数:70,代码来源:menu.py


注:本文中的ui.UI.status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。