本文整理汇总了Python中foobnix.gui.model.FModel.add_parent方法的典型用法代码示例。如果您正苦于以下问题:Python FModel.add_parent方法的具体用法?Python FModel.add_parent怎么用?Python FModel.add_parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类foobnix.gui.model.FModel
的用法示例。
在下文中一共展示了FModel.add_parent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_playlist
# 需要导入模块: from foobnix.gui.model import FModel [as 别名]
# 或者: from foobnix.gui.model.FModel import add_parent [as 别名]
def create_playlist(self):
name = one_line_dialog(_("Create new playlist"), self.controls.main_window, message_text1=_("Enter playlist name"))
if not name:
return
bean = self.get_selected_bean()
folder_bean = FModel(name)
if bean:
if bean.is_file:
folder_bean.add_parent(bean.parent_level)
else:
folder_bean.add_parent(bean.level)
self.append(folder_bean)
示例2: create_folder
# 需要导入模块: from foobnix.gui.model import FModel [as 别名]
# 或者: from foobnix.gui.model.FModel import add_parent [as 别名]
def create_folder(self, a):
model, tree_path, row = a # @UnusedVariable
file_path = row[self.path[0]]
new_folder_path = create_folder_dialog(file_path)
bean = FModel(os.path.basename(new_folder_path), new_folder_path).add_is_file(False)
if os.path.isfile(file_path):
bean.add_parent(row[self.parent_level[0]])
elif os.path.isdir(file_path):
bean.add_parent(row[self.level[0]])
else:
logging.error("So path doesn't exist")
self.tree_append(bean)
self.save_tree()
示例3: on_add_station
# 需要导入模块: from foobnix.gui.model import FModel [as 别名]
# 或者: from foobnix.gui.model.FModel import add_parent [as 别名]
def on_add_station(self):
name, url = two_line_dialog(_("Add New Radio Station"),
parent = self.controls.main_window,
message_text1 = _("Enter station name and URL"),
message_text2 = None,
entry_text1 = None,
entry_text2 = "http://")
if not name or not url:
return
bean = self.get_selected_bean()
new_bean = FModel(name, url).add_type(FTYPE_RADIO).add_is_file(True)
if bean:
if bean.is_file:
new_bean.add_parent(bean.parent_level)
else:
new_bean.add_parent(bean.level)
self.append(new_bean)
示例4: auto_add_user_station
# 需要导入模块: from foobnix.gui.model import FModel [as 别名]
# 或者: from foobnix.gui.model.FModel import add_parent [as 别名]
def auto_add_user_station(self):
if os.path.isfile(CACHE_RADIO_FILE) and os.path.getsize(CACHE_RADIO_FILE) > 0:
with open(CACHE_RADIO_FILE, 'r') as f:
list = f.readlines()
parent_level_for_depth = {}
previous = {"bean": None, "depth": 0, "name": '', "url": ''}
for line in list:
depth = self.simbol_counter(line, '-')
try:
name = line[depth : line.index('#')]
except ValueError, e:
logging.warning('\'#\' ' + str(e) + ' in line \"' + line + '\"')
continue
url = line[line.index('#') + 1 : -1]
bean = FModel(name)
if url:
bean.add_is_file(True).add_path(url).add_type(FTYPE_RADIO)
if previous["depth"] < depth:
bean.add_parent(previous["bean"].level)
elif previous["depth"] > depth:
bean.add_parent(parent_level_for_depth[depth])
else:
if previous["bean"]:
bean.add_parent(previous["bean"].parent_level)
self.append(bean)
parent_level_for_depth[depth] = bean.parent_level
previous = {"bean": bean, "depth": depth, "name": name, "url": url}