本文整理汇总了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)
示例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