本文整理汇总了Python中ui.Ui.build_loading方法的典型用法代码示例。如果您正苦于以下问题:Python Ui.build_loading方法的具体用法?Python Ui.build_loading怎么用?Python Ui.build_loading使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ui.Ui
的用法示例。
在下文中一共展示了Ui.build_loading方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from ui import Ui [as 别名]
# 或者: from ui.Ui import build_loading [as 别名]
class Menu:
def __init__(self):
reload(sys)
sys.setdefaultencoding('UTF-8')
self.datatype = 'main'
self.title = '网易云音乐'
self.datalist = ['排行榜', '艺术家', '新碟上架', '精选歌单', '我的歌单', 'DJ节目', '打碟', '收藏', '搜索', '帮助']
self.offset = 0
self.index = 0
self.presentsongs = []
self.player = Player()
self.ui = Ui()
self.netease = NetEase()
self.screen = curses.initscr()
self.screen.keypad(1)
self.step = STEP
self.stack = []
self.djstack = []
self.userid = None
self.username = None
try:
sfile = file(home + "/netease-musicbox/flavor.json",'r')
data = json.loads(sfile.read())
self.collection = data['collection']
self.account = data['account']
sfile.close()
except:
self.collection = []
self.account = {}
def start(self):
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, self.index, self.step)
self.stack.append([self.datatype, self.title, self.datalist, self.offset, self.index])
while True:
datatype = self.datatype
title = self.title
datalist = self.datalist
offset = self.offset
idx = index = self.index
step = self.step
stack = self.stack
djstack = self.djstack
key = self.screen.getch()
self.ui.screen.refresh()
# 退出
if key == ord('q'):
break
# 上移
elif key == ord('k'):
self.index = carousel(offset, min( len(datalist), offset + step) - 1, idx-1 )
# 下移
elif key == ord('j'):
self.index = carousel(offset, min( len(datalist), offset + step) - 1, idx+1 )
# 向上翻页
elif key == ord('u'):
if offset == 0:
continue
self.offset -= step
# e.g. 23 - 10 = 13 --> 10
self.index = (index-step)//step*step
# 向下翻页
elif key == ord('d'):
if offset + step >= len( datalist ):
continue
self.offset += step
# e.g. 23 + 10 = 33 --> 30
self.index = (index+step)//step*step
# 前进
elif key == ord('l') or key == 10:
if self.datatype == 'songs' or self.datatype == 'djchannels' or self.datatype == 'help':
continue
self.ui.build_loading()
self.dispatch_enter(idx)
self.index = 0
self.offset = 0
# 回退
elif key == ord('h'):
# if not main menu
if len(self.stack) == 1:
continue
up = stack.pop()
self.datatype = up[0]
self.title = up[1]
self.datalist = up[2]
self.offset = up[3]
self.index = up[4]
# 搜索
elif key == ord('f'):
self.search()
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from ui import Ui [as 别名]
# 或者: from ui.Ui import build_loading [as 别名]
class Menu:
def __init__(self):
reload(sys)
sys.setdefaultencoding('UTF-8')
self.data_type = 'main'
# Title of the application
self.title = '网易云音乐'
# Main-menu list
self.data_list = ['排行榜', '艺术家', '新碟上架', '精选歌单', '我的歌单', 'DJ节目', '打碟', '收藏', '搜索', '帮助']
# Which page of the data_list is displayed (data_list may be displayed in multiple pages
self.page_index = 0
# The index of the current selected line
self.current_line_index = 0
self.present_songs = []
self.player = Player()
self.ui = Ui()
self.netease = NetEase()
self.screen = curses.initscr()
self.screen.keypad(1)
self.page_size = 10 # The number of lines that can be displayed on one page.
self.stack = []
self.dj_stack = []
self.user_id = None
self.user_name = None
# Read in the collection and account in flavor.json
try:
config_file = file(Constant.conf_dir + "/flavor.json", 'r')
data = json.loads(config_file.read())
self.collection = data['collection']
self.account = data['account']
config_file.close()
except:
self.collection = []
self.account = {}
def start(self):
# draw the main menu
self.ui.build_menu(self.data_type, self.title, self.data_list, self.page_index, self.current_line_index, self.page_size)
# push current menu into stack
self.stack.append([self.data_type, self.title, self.data_list, self.page_index, self.current_line_index])
# Main loop
while True:
# refresh the menu
data_type = self.data_type
title = self.title
data_list = self.data_list
page_index = self.page_index
idx = current_line_index = self.current_line_index
page_size = self.page_size
stack = self.stack
dj_stack = self.dj_stack
self.ui.screen.refresh()
# fetch a user's command
key = self.screen.getch()
# quit
if key == ord('q'):
break
# move up
elif key == ord('k') or key == curses.KEY_UP:
self.current_line_index = carousel(page_index, min(len(data_list), page_index + page_size) - 1, idx - 1)
# DEBUG
# self.ui.screen.addstr(0, 0,'current_line_index: {}, begin: {}, end: {}'.format(self.current_line_index, page_index, min(len(data_list), page_index+page_size)))
# move down
elif key == ord('j') or key == curses.KEY_DOWN:
self.current_line_index = carousel(page_index, min(len(data_list), page_index + page_size) - 1, idx + 1)
# DEBUG
# self.ui.screen.addstr(0, 0,'current_line_index: {}, begin: {}, end: {}'.format(self.current_line_index, page_index, min(len(data_list), page_index+page_size)))
# number shortcut
elif ord('0') <= key <= ord('9'):
if self.data_type == 'songs' or self.data_type == 'djchannels' or self.data_type == 'help':
continue
idx = key - ord('0')
self.ui.build_menu(self.data_type, self.title, self.data_list, self.page_index, idx, self.page_size)
self.ui.build_loading()
self.dispatch_enter(idx)
self.current_line_index = 0
self.page_index = 0
# 向上翻页
elif key == ord('u') or key == curses.KEY_PPAGE:
if page_index == 0:
continue
self.page_index -= page_size
# Move to first line of the page
self.current_line_index = (current_line_index - page_size) // page_size * page_size
# 向下翻页
elif key == ord('d') or key == curses.KEY_NPAGE:
if page_index + page_size >= len(data_list):
continue
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from ui import Ui [as 别名]
# 或者: from ui.Ui import build_loading [as 别名]
class Menu:
def __init__(self):
reload(sys)
sys.setdefaultencoding("UTF-8")
self.datatype = "main"
self.title = "网易云音乐"
self.datalist = ["排行榜", "艺术家", "新碟上架", "精选歌单", "我的歌单", "DJ节目", "打碟", "收藏", "搜索", "帮助"]
self.offset = 0
self.index = 0
self.storage = Storage()
self.storage.load()
self.collection = self.storage.database["collections"][0]
self.player = Player()
self.ui = Ui()
self.netease = NetEase()
self.screen = curses.initscr()
self.screen.keypad(1)
self.step = 10
self.stack = []
self.djstack = []
self.userid = None
self.username = None
self.resume_play = True
signal.signal(signal.SIGWINCH, self.change_term)
signal.signal(signal.SIGINT, self.send_kill)
self.START = time.time()
def change_term(self, signum, frame):
self.ui.screen.clear()
self.ui.screen.refresh()
def send_kill(self, signum, fram):
self.player.stop()
self.storage.save()
curses.endwin()
sys.exit()
def start(self):
self.START = time.time() // 1
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, self.index, self.step, self.START)
self.ui.build_process_bar(
self.player.process_location,
self.player.process_length,
self.player.playing_flag,
self.player.pause_flag,
self.storage.database["player_info"]["playing_mode"],
)
self.stack.append([self.datatype, self.title, self.datalist, self.offset, self.index])
while True:
datatype = self.datatype
title = self.title
datalist = self.datalist
offset = self.offset
idx = index = self.index
step = self.step
stack = self.stack
djstack = self.djstack
self.screen.timeout(500)
key = self.screen.getch()
self.ui.screen.refresh()
# term resize
if key == -1:
self.ui.update_size()
self.player.update_size()
# 退出
if key == ord("q"):
break
# 退出并清除用户信息
if key == ord("w"):
self.storage.database["user"] = {"username": "", "password": ""}
break
# 上移
elif key == ord("k"):
self.index = carousel(offset, min(len(datalist), offset + step) - 1, idx - 1)
self.START = time.time()
# 下移
elif key == ord("j"):
self.index = carousel(offset, min(len(datalist), offset + step) - 1, idx + 1)
self.START = time.time()
# 数字快捷键
elif ord("0") <= key <= ord("9"):
if self.datatype == "songs" or self.datatype == "djchannels" or self.datatype == "help":
continue
idx = key - ord("0")
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, idx, self.step, self.START)
self.ui.build_loading()
self.dispatch_enter(idx)
self.index = 0
self.offset = 0
# 向上翻页
elif key == ord("u"):
if offset == 0:
continue
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from ui import Ui [as 别名]
# 或者: from ui.Ui import build_loading [as 别名]
#.........这里部分代码省略.........
# 上移
elif key == ord('k'):
# turn page if at beginning
if idx == offset:
if offset == 0:
continue
self.offset -= step
# 移动光标到最后一列
self.index = offset - 1
else:
self.index = carousel(offset, min( len(datalist), offset + step) - 1, idx - 1)
self.START = time.time()
# 下移
elif key == ord('j'):
# turn page if at end
if idx == min( len(datalist), offset + step) - 1:
if offset + step >= len( datalist ):
continue
self.offset += step
# 移动光标到第一列
self.index = offset + step
else:
self.index = carousel(offset, min( len(datalist), offset + step) - 1, idx + 1)
self.START = time.time()
# 数字快捷键
elif ord('0') <= key <= ord('9'):
if self.datatype == 'songs' or self.datatype == 'djchannels' or self.datatype == 'help':
continue
idx = key - ord('0')
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, idx, self.step, self.START)
self.ui.build_loading()
self.dispatch_enter(idx)
self.index = 0
self.offset = 0
# 向上翻页
elif key == ord('u'):
if offset == 0:
continue
self.START = time.time()
self.offset -= step
# e.g. 23 - 10 = 13 --> 10
self.index = (index - step) // step * step
# 向下翻页
elif key == ord('d'):
if offset + step >= len(datalist):
continue
self.START = time.time()
self.offset += step
# e.g. 23 + 10 = 33 --> 30
self.index = (index + step) // step * step
# 前进
elif key == ord('l') or key == 10:
if self.datatype == 'songs' or self.datatype == 'djchannels' or self.datatype == 'help' or len(self.datalist) <= 0:
continue
self.START = time.time()
self.ui.build_loading()
self.dispatch_enter(idx)
self.index = 0
示例5: __init__
# 需要导入模块: from ui import Ui [as 别名]
# 或者: from ui.Ui import build_loading [as 别名]
#.........这里部分代码省略.........
# 上移
elif key == ord("k"):
# turn page if at beginning
if idx == offset:
if offset == 0:
continue
self.offset -= step
# 移动光标到最后一列
self.index = offset - 1
else:
self.index = carousel(offset, min(len(datalist), offset + step) - 1, idx - 1)
self.START = time.time()
# 下移
elif key == ord("j"):
# turn page if at end
if idx == min(len(datalist), offset + step) - 1:
if offset + step >= len(datalist):
continue
self.offset += step
# 移动光标到第一列
self.index = offset + step
else:
self.index = carousel(offset, min(len(datalist), offset + step) - 1, idx + 1)
self.START = time.time()
# 数字快捷键
elif ord("0") <= key <= ord("9"):
if self.datatype == "songs" or self.datatype == "djchannels" or self.datatype == "help":
continue
idx = key - ord("0")
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, idx, self.step, self.START)
self.ui.build_loading()
self.dispatch_enter(idx)
self.index = 0
self.offset = 0
# 向上翻页
elif key == ord("u"):
if offset == 0:
continue
self.START = time.time()
self.offset -= step
# e.g. 23 - 10 = 13 --> 10
self.index = (index - step) // step * step
# 向下翻页
elif key == ord("d"):
if offset + step >= len(datalist):
continue
self.START = time.time()
self.offset += step
# e.g. 23 + 10 = 33 --> 30
self.index = (index + step) // step * step
# 前进
elif key == ord("l") or key == 10:
if (
self.datatype == "songs"
or self.datatype == "djchannels"
or self.datatype == "help"
or len(self.datalist) <= 0
):
示例6: __init__
# 需要导入模块: from ui import Ui [as 别名]
# 或者: from ui.Ui import build_loading [as 别名]
class Menu:
def __init__(self):
reload(sys)
sys.setdefaultencoding('UTF-8')
self.datatype = 'main'
self.title = '网易云音乐'
self.datalist = ['排行榜', '艺术家', '新碟上架', '精选歌单', '我的歌单', 'DJ节目', '打碟', '收藏', '搜索', '帮助']
self.offset = 0
self.index = 0
self.storage = Storage()
self.storage.load()
self.collection = self.storage.database['collections'][0]
self.player = Player()
self.cache = Cache()
self.ui = Ui()
self.netease = NetEase()
self.screen = curses.initscr()
self.screen.keypad(1)
self.step = 10
self.stack = []
self.djstack = []
self.userid = None
self.username = None
self.resume_play = True
signal.signal(signal.SIGWINCH, self.change_term)
signal.signal(signal.SIGINT, self.send_kill)
self.START = time.time()
def change_term(self, signum, frame):
self.ui.screen.clear()
self.ui.screen.refresh()
def send_kill(self, signum, fram):
self.player.stop()
self.cache.quit()
self.storage.save()
curses.endwin()
sys.exit()
def start(self):
self.START = time.time() // 1
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, self.index, self.step, self.START)
self.ui.build_process_bar(self.player.process_location, self.player.process_length, self.player.playing_flag,
self.player.pause_flag, self.storage.database['player_info']['playing_mode'])
self.stack.append([self.datatype, self.title, self.datalist, self.offset, self.index])
while True:
datatype = self.datatype
title = self.title
datalist = self.datalist
offset = self.offset
idx = index = self.index
step = self.step
stack = self.stack
djstack = self.djstack
self.screen.timeout(500)
key = self.screen.getch()
self.ui.screen.refresh()
# term resize
if key == -1:
self.ui.update_size()
self.player.update_size()
# 退出
if key == ord('q'):
break
# 退出并清除用户信息
if key == ord('w'):
self.storage.database['user'] = {
"username": "",
"password": "",
}
break
# 上移
elif key == ord('k'):
self.index = carousel(offset, min(len(datalist), offset + step) - 1, idx - 1)
self.START = time.time()
# 下移
elif key == ord('j'):
self.index = carousel(offset, min(len(datalist), offset + step) - 1, idx + 1)
self.START = time.time()
# 数字快捷键
elif ord('0') <= key <= ord('9'):
if self.datatype == 'songs' or self.datatype == 'djchannels' or self.datatype == 'help':
continue
idx = key - ord('0')
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, idx, self.step, self.START)
self.ui.build_loading()
self.dispatch_enter(idx)
self.index = 0
self.offset = 0
# 向上翻页
elif key == ord('u'):
if offset == 0:
continue
#.........这里部分代码省略.........
示例7: Menu
# 需要导入模块: from ui import Ui [as 别名]
# 或者: from ui.Ui import build_loading [as 别名]
#.........这里部分代码省略.........
# turn page if at beginning
if idx == offset:
if offset == 0:
continue
self.offset -= step
# 移动光标到最后一列
self.index = offset - 1
else:
self.index = carousel(offset, min(
len(datalist), offset + step) - 1, idx - 1)
self.START = time.time()
# 下移
elif key == ord('j'):
# turn page if at end
if idx == min(len(datalist), offset + step) - 1:
if offset + step >= len(datalist):
continue
self.offset += step
# 移动光标到第一列
self.index = offset + step
else:
self.index = carousel(offset, min(
len(datalist), offset + step) - 1, idx + 1)
self.START = time.time()
# 数字快捷键
elif ord('0') <= key <= ord('9'):
if self.datatype == ('songs', 'djchannels', 'help'):
continue
idx = key - ord('0')
self.ui.build_menu(self.datatype, self.title, self.datalist,
self.offset, idx, self.step, self.START)
self.ui.build_loading()
self.dispatch_enter(idx)
self.index = 0
self.offset = 0
# 向上翻页
elif key == ord('u'):
if offset == 0:
continue
self.START = time.time()
self.offset -= step
# e.g. 23 - 10 = 13 --> 10
self.index = (index - step) // step * step
# 向下翻页
elif key == ord('d'):
if offset + step >= len(datalist):
continue
self.START = time.time()
self.offset += step
# e.g. 23 + 10 = 33 --> 30
self.index = (index + step) // step * step
# 前进
elif key == ord('l') or key == 10:
if self.datatype == ('songs', 'djchannels',
'help') or len(self.datalist) <= 0:
continue
self.START = time.time()
self.ui.build_loading()
self.dispatch_enter(idx)
示例8: __init__
# 需要导入模块: from ui import Ui [as 别名]
# 或者: from ui.Ui import build_loading [as 别名]
#.........这里部分代码省略.........
djstack = self.djstack
curses.flushinp()
key = self.screen.getch()
idx = index = self.index
#self.key_m()
#self.next=self.player.return_idx()[2]
if not datatype in ['songs','djchannels']:
self.kill_p=1 #不在播放列表songs or djchannels,不跳转
else:
self.kill_p=0
self.ui.screen.refresh()
# 退出
if key == ord('q'):
#self.kill_p=1 #结束循环
break
# 上移
elif key == ord('k') or key== curses.KEY_UP: #↑
self.index = carousel(offset, min( len(datalist), offset + step) - 1, idx-1 )
self.interrupt_delay()
# 下移
elif key == ord('j') or key==curses.KEY_DOWN: #↓
self.index = carousel(offset, min( len(datalist), offset + step) - 1, idx+1 )
self.interrupt_delay()
# 数字快捷键
elif ord('0') <= key <= ord('9'):
if self.datatype == 'songs' or self.datatype == 'djchannels' or self.datatype == 'help':
continue
idx = key - ord('0')
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, idx, self.step)
self.ui.build_loading()
self.dispatch_enter(idx)
self.index = 0
self.offset = 0
# 向上翻页
elif key == ord('u'):
if offset == 0:
continue
self.offset -= step
# e.g. 23 - 10 = 13 --> 10
self.index = (index-step)//step*step
self.interrupt_delay()
# 向下翻页
elif key == ord('d'):
if offset + step >= len( datalist ):
continue
self.offset += step
# e.g. 23 + 10 = 33 --> 30
self.index = (index+step)//step*step
self.interrupt_delay()
# 前进
elif key == ord('l') or key == 10 or key == curses.KEY_RIGHT: #→
if self.datatype == 'songs' or self.datatype == 'djchannels' or self.datatype == 'help':
continue
self.ui.build_loading()
self.dispatch_enter(idx)
self.index = 0
self.offset = 0