本文整理汇总了Python中library.Library.update方法的典型用法代码示例。如果您正苦于以下问题:Python Library.update方法的具体用法?Python Library.update怎么用?Python Library.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类library.Library
的用法示例。
在下文中一共展示了Library.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MobileMMAUI
# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import update [as 别名]
class MobileMMAUI(Widget):
#config = ConfigParser()
#config.read(CONFIG_FILENAME)
def __init__(self, library_path, *args, **kwargs):
Widget.__init__(self, *args, **kwargs)
# Update grooves at startup
midi.update_grooves()
# Library od mma files
self.mma_library = Library(library_path)
self.mma_library.update()
self.key_list.adapter.data = sorted(self.mma_library.key_sig)
self.fill_groove_tree()
self.update_tune_list()
def play_pause(self):
"""Play the selected filename.
"""
logger.debug("Play button pressed")
filename = os.path.join(self.mma_library.path,
self.tune_list.adapter.selection[0].text)
try:
midi.play(filename)
except Exception as err:
logger.exception(err)
def stop(self):
"""Stop playing.
"""
logger.debug("Stop button pressed")
midi.stop()
def file_content(self, filename):
"""Return content of a mma test file.
"""
logger.debug("Retrieve content of %s" % filename)
if filename.endswith(('.mid', '.midi')):
return "MIDI file"
assert filename.lower().endswith(".mma")
with open(filename, "rt") as fid:
text = fid.read()
return text
def update_grooves(self):
midi.init()
def fill_groove_tree(self):
_populate_tree_view(self.groove_tree, self.groove_tree.root, None,
self.mma_library.groove_tree)
def toggle_groove(self, groove_item):
if groove_item.nodes:
for child in groove_item.nodes:
child.state = groove_item.state
else:
self.update_tune_list()
def selected_grooves(self, _tree=None):
# Initilaization
selected = set()
if _tree is None:
_tree = self.groove_tree.root
# Recursive filling
for groove in _tree.nodes:
if groove.state == 'down':
selected.add(groove.text)
selected = selected | self.selected_grooves(groove)
return selected
def update_tune_list(self):
data = sorted(self.mma_library.get_match(self.selected_grooves()))
self.tune_list.adapter = ListAdapter(
data=data,
selection_mode='single',
allow_empty_selection=False,
cls=ListItemButton)