本文整理汇总了Python中kivy.uix.treeview.TreeView.remove_node方法的典型用法代码示例。如果您正苦于以下问题:Python TreeView.remove_node方法的具体用法?Python TreeView.remove_node怎么用?Python TreeView.remove_node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.treeview.TreeView
的用法示例。
在下文中一共展示了TreeView.remove_node方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FileCheckUi
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import remove_node [as 别名]
class FileCheckUi(App):
tv = None
def build(self):
l = BoxLayout(orientation='vertical')
b = Button(text='Run')
b.bind(on_press=self.btn_run)
b.size_hint = 1, 1
sv = ScrollView()
sv.size_hint = 1, 10
self.tv = TreeView(root_options=dict(text='Results'))
self.tv.size_hint = 1, None
self.tv.bind(minimum_height = self.tv.setter('height'))
sv.add_widget(self.tv)
l.add_widget(b)
l.add_widget(sv)
return l
def list2tree(self, lbl, lst):
tvn = self.tv.add_node(TreeViewLabel(text=lbl))
for t in lst:
self.tv.add_node(TreeViewLabel(text=t), tvn)
def report(self, added, error, missing):
self.report_clear ()
self.list2tree ('Added', added)
self.list2tree('Error', error)
self.list2tree('Missing', missing)
def report_clear(self):
while len (self.tv.root.nodes) > 0:
self.tv.remove_node (self.tv.root.nodes[0])
def btn_run(self, value):
fdb = '/sdcard/Download/filedb.csv'
self.dw = None
self.dw = CsvTest.DirWalker ()
self.dw.filedb.load( fdb)
self.dw.walk ( '/sdcard/Download')
self.dw.filedb.save (fdb)
self.report( self.dw.filedb.added,
self.dw.filedb.errors,
self.dw.filedb.not_visited())
示例2: MainScreen
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import remove_node [as 别名]
#.........这里部分代码省略.........
self.file_view.bind(minimum_height=self.file_view.setter('height'))
self.scroll_view.add_widget(self.file_view)
for file_name in file_names:
self.file_view.add_node(TreeViewLabel(text=file_name))
self.max_storage_size = controller.get_max_storage_size()
self.usage_bar.max = self.max_storage_size
self.update_storage_view()
def dismiss_popup(self):
self._popup.dismiss()
def select_file(self):
content = LoadDialog(load=self.upload_file, cancel=self.dismiss_popup)
self._popup = Popup(title="Upload file", content=content, size_hint=(0.9, 0.9))
self._popup.open()
def update_storage_view(self):
self.used_storage_size = controller.get_used_storage_size()
self.usage_label.text = controller.get_data_type_format(self.used_storage_size, self.max_storage_size)
self.usage_bar.value = self.used_storage_size
def get_free_storage_size(self):
return self.max_storage_size - self.used_storage_size
def split_input_file_task(self):
controller.save_file_input(self.filename, self.file_input, AES_CRYPTO)
self.file_view.add_node(TreeViewLabel(text=self.filename))
self.update_storage_view()
try:
controller.update_data(self.filename, AES_CRYPTO)
except CloudTokenError as err:
open_popup_error('Cloud Token', err)
self.stop.set()
def upload_file_task(self):
with open(os.path.join(self.path, self.filename[0]), utils.READ_BINARY_MODE) as file:
self.file_input = file.read()
if controller.is_storage_available(len(self.file_input), self.get_free_storage_size()):
self.filename = os.path.basename(self.filename[0])
self.split_input_file_task()
else:
open_popup('Upload Error', 'Not enough storage available.')
self.stop.set()
def upload_file(self, path, filename):
self.path = path
self.filename = filename
threading.Thread(target=self.upload_file_task).start()
self.dismiss_popup()
def get_selected_node(self):
selected_node = self.file_view.selected_node
if selected_node is None:
raise NoSelectedNode('No file has been selected.')
return selected_node
def select_location(self):
try:
self.selected_node_text = self.get_selected_node().text
except NoSelectedNode as err:
open_popup_error('Download error', err)
return
content = SaveDialog(save=self.save, cancel=self.dismiss_popup)
content.file_name_label.text = self.selected_node_text
self._popup = Popup(title="Download file", content=content,
size_hint=(0.9, 0.9))
self._popup.open()
def download_file_task(self):
try:
controller.download_selected_file(self.selected_node_text, self.path, self.filename, AES_CRYPTO)
open_popup('Download file', 'Download was successful')
except (DownloadFileError, FileSizeError, CloudTokenError) as err:
open_popup_error('Download error', err)
return
self.stop.set()
def save(self, path, filename):
self.path = path
self.filename = filename
threading.Thread(target=self.download_file_task).start()
self.dismiss_popup()
def delete_file_task(self):
controller.delete_selected_node(self.selected_node_text)
self.update_storage_view()
self.stop.set()
def delete_selected_file(self):
try:
self.selected_node = self.get_selected_node()
self.selected_node_text = self.selected_node.text
except NoSelectedNode as err:
open_popup_error('Delete error', err)
return
self.file_view.remove_node(self.selected_node)
threading.Thread(target=self.delete_file_task).start()