本文整理汇总了Python中kivy.uix.treeview.TreeView.add_node方法的典型用法代码示例。如果您正苦于以下问题:Python TreeView.add_node方法的具体用法?Python TreeView.add_node怎么用?Python TreeView.add_node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.treeview.TreeView
的用法示例。
在下文中一共展示了TreeView.add_node方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_content
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
def update_content(self, *args):
widget = self.console.widget
if not widget:
return
from kivy.uix.scrollview import ScrollView
self.root = root = BoxLayout()
self.sv = sv = ScrollView(scroll_type=["bars", "content"])
treeview = TreeView(hide_root=True, size_hint_y=None)
treeview.bind(minimum_height=treeview.setter("height"))
keys = list(widget.properties().keys())
keys.sort()
node = None
wk_widget = weakref.ref(widget)
for key in keys:
text = '%s' % key
node = TreeViewProperty(text=text, key=key, widget_ref=wk_widget)
node.bind(is_selected=self.show_property)
try:
widget.bind(**{
key: partial(self.update_node_content, weakref.ref(node))
})
except:
pass
treeview.add_node(node)
root.add_widget(sv)
sv.add_widget(treeview)
self.console.set_content(root)
示例2: getTreeViewAsFiles
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
def getTreeViewAsFiles(self):
try:
tv = TreeView(hide_root=True)
tv.size_hint = 1, None
tv.bind(minimum_height = tv.setter('height'))
for key in self.config_files:
newnode = tv.add_node(TreeViewLabel(text=self.config_files[key].filename, font_size=self.label_font_size, color=self.filename_label_color))
for child_filename in self.config_files[key].child_files:
self._addFileNodeToFileTreeView(tv, newnode, self.config_files[key].child_files[child_filename])
for configkey in self.config_files[key].config:
if isinstance(self.config_files[key].config[configkey], dict):
self._addDictNodeToFileTreeView(tv, newnode, configkey, self.config_files[key].config[configkey])
else:
tv.add_node(TreeViewLabel(text=str(configkey) + ':' + str(self.config_files[key].config[configkey]), font_size=self.label_font_size, color=self.key_label_color), newnode)
scv = ScrollView(pos = (0, 0), bar_width = 10)
scv.add_widget(tv)
return scv
except:
e = sys.exc_info()[0]
self.log.exception("Error: %s" % e )
raise
示例3: agacGorunumu
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
class agacGorunumu(App):
def build(self):
duzen=BoxLayout(orientation='vertical')
self.agac_koku = TreeView(hide_root=True, size_hint_y=0.8)
kuruyemisler=[('Sert Kabuklular',('Ceviz', 'Fındık', 'Badem')),
('Meyve Kuruları',('Dut', 'Vişne', 'Kayısı', 'İncir'))]
for ky in kuruyemisler:
eb=self.agac_koku.add_node(TreeViewLabel(text=ky[0]))
for k in ky[1]:
self.agac_koku.add_node(TreeViewLabel(text=k),eb)
duzen.add_widget(self.agac_koku)
dgm=Button(text='Elemanları Yaz', size_hint_y=0.2)
dgm.bind(on_press=self.elemanlari_yaz)
duzen.add_widget(dgm)
return duzen
def elemanlari_yaz(self, *args):
for eb in self.agac_koku.iterate_all_nodes():
print eb.level, eb.text
if self.agac_koku.selected_node:
print "Seçili Eleman", self.agac_koku.selected_node.text
print self.agac_koku.get_node_at_pos((1,1))
示例4: build
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
def build(self):
agac_koku = TreeView()
ebeveyn1=agac_koku.add_node(TreeViewLabel(text='Ebeveyn 1'))
cocuk11=agac_koku.add_node(TreeViewLabel(text='Çocuk 1 1'), ebeveyn1)
cocuk12=agac_koku.add_node(TreeViewLabel(text='Çocuk 1 2'), ebeveyn1)
cocuk121=agac_koku.add_node(TreeViewLabel(text='Çocuk 1 2 1'), cocuk12)
cocuk122=agac_koku.add_node(TreeViewLabel(text='Çocuk 1 2 2'), cocuk12)
ebeveyn2=agac_koku.add_node(TreeViewLabel(text='Ebeveyn 2'))
cocuk21=agac_koku.add_node(TreeViewLabel(text='Çocuk 2 1'), ebeveyn2)
cocuk22=agac_koku.add_node(TreeViewLabel(text='Çocuk 2 2'), ebeveyn2)
return agac_koku
示例5: fill_tree
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
def fill_tree(self, filtre):
self.scroll.clear_widgets()
tree = TreeView(hide_root=True, size_hint_y=None, size_hint_x = 0.6)
tree.bind(minimum_height=tree.setter('height'),
selected_node=self.show_details)
self.scroll.add_widget(tree)
for uv in self.uvs:
if uv[0].startswith(filtre.upper()) and uv[1] != 0:
node = TreeViewLabel(text=u"%s (%s €)" % (uv[0],
uv[1]*0.06),
font_size=30, size_hint_y=None,
padding=(20,20))
tree.add_node(node)
self.tree = tree
示例6: agacGorunumu
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
class agacGorunumu(App):
def build(self):
duzen=BoxLayout(orientation='vertical')
self.agac_koku = TreeView(hide_root=True)
kuruyemisler=[('Sert Kabuklular',('Ceviz', 'Fındık', 'Badem')),
('Meyve Kuruları',('Dut', 'Vişne', 'Kayısı', 'İncir'))]
for ky in kuruyemisler:
eb=self.agac_koku.add_node(TreeViewLabel(text=ky[0]))
for k in ky[1]:
self.agac_koku.add_node(TreeViewLabel(text=k),eb)
duzen.add_widget(self.agac_koku)
return duzen
示例7: FileCheckUi
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_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())
示例8: POSFMApp
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
class POSFMApp(App):
def build(self):
layout = FloatLayout()
self.tv = TreeView(root_options=dict(text='Tree One'), hide_root=True, indent_level=0, indent_start=0)
self.tv.size_hint = 1, None
self.tv.bind(minimum_height = self.tv.setter('height'))
self.populate_tree_view(self.tv)
self.camera = Button(text = 'Camera', size_hint =(1/3.,.23),
background_color=[1,0,0,.6], pos_hint={'x':0,'y':0})
self.add = Button(text = 'Add', size_hint =(1/3.,.23),
background_color=[1,0,0,.6], pos_hint={'x':1/3.,'y':0})
self.sort = Button(text = 'Sort', size_hint =(1/3.,.23),
background_color=[1,0,0,.6], pos_hint={'x':2/3.,'y':0})
root = ScrollView(pos = (0, 0))
root.add_widget(self.tv)
layout.add_widget(root)
layout.add_widget(self.camera)
layout.add_widget(self.add)
layout.add_widget(self.sort)
return layout
def populate_tree_view(self, tv):
for i, item in enumerate(foodlist):
if item.categ not in usedcat.keys():
catbutton = TreeViewButton(text='%s' % item.categ, font_size = '50sp',
size = (100, 450), background_color=[1,1,0,1])
catbutton.bind(on_press=self.cat_clicked)
g = self.tv.add_node(catbutton)
usedcat[item.categ] = g
else:
g = usedcat[item.categ]
itembutton = TreeViewButton(text='%s' % item.name, font_size = '30sp',
size = (100,150), background_color=[0,1,1,1])
itembutton.outline_height = 10
self.tv.add_node(itembutton, g)
def cat_clicked(self, button):
self.tv.toggle_node(button)
示例9: getMergedTreeView
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
def getMergedTreeView(self):
try:
tv = TreeView(hide_root=True)
tv.size_hint = 1, None
tv.bind(minimum_height = tv.setter('height'))
for key in self.config_files:
merged_dict = self.config_files[key].get_merged_config()
for key in merged_dict:
if isinstance(merged_dict[key], dict):
newnode = tv.add_node(TreeViewLabel(text=str(key), font_size=self.label_font_size, color=self.key_label_color))
self._addNodeToMergedTreeView(tv, newnode, merged_dict[key])
else:
newnode = tv.add_node(TreeViewLabel(text=str(key) + ':' + str(merged_dict[key]), font_size=self.label_font_size, color=self.key_label_color))
scv = ScrollView(pos = (0, 0), bar_width = 10)
scv.add_widget(tv)
return scv
except:
e = sys.exc_info()[0]
self.log.exception("Error: %s" % e )
raise
示例10: build
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
def build(self):
root = BoxLayout(orientation='horizontal', padding=20, spacing=20)
tree = TreeView(size_hint=(None, 1), width=200, hide_root=True, indent_level=0)
tree.bind(selected_node=self.on_select_node)
n = tree.add_node(TreeViewLabel(text=u'Меню', is_open=True, no_selection=True))
n = tree.add_node(TreeViewLabel(text=u'Управление', is_open=True, no_selection=True))
tree.add_node(TreeViewLabel(text=u'Открыть'), n, )
tree.add_node(TreeViewLabel(text=u'Закрыть'), n)
n = tree.add_node(TreeViewLabel(text=u'Настройки', is_open=True, no_selection=True))
#tree.add_node(TreeViewLabel(text='Что то еще'), n)
root.add_widget(tree)
self.content = content = BoxLayout()
root.add_widget(content)
sc = Showcase()
sc.content.add_widget(root)
return sc
示例11: show_key
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
def show_key(self, gloup):
tree = TreeView(size_hint=(1, 1), hide_root=True,
indent_level=20)
def getReadableSize(size):
units = ['o', 'Ko', 'Mo', 'Go']
unit = 0
while size > 1024 and unit < 3:
size = size / 1024.0
unit = unit + 1
return "%.2f %s" % (size, units[unit])
tree.bind(selected_node=self.show_file)
self.content.clear_widgets()
self.content.add_widget(tree)
dirNodes = dict()
# la racine
dirNodes[path_to_watch] = tree.add_node(TreeViewLabel(
text="Ordinateur", is_open=True, no_selection=True))
for root, dirs, files in os.walk(path_to_watch):
for diritem in dirs:
fulldiritem = os.path.join(root, diritem)
dirNodes[fulldiritem] = tree.add_node(TreeViewLabel(
text=diritem, is_open=False, no_selection=True), dirNodes[root])
for fileitem in files:
(a, ext) = os.path.splitext(fileitem)
if fileitem[0] !='.':
label = "%s (%s)" % (fileitem, getReadableSize(os.path.getsize(os.path.join(root, fileitem)))) #FIXME Aligner à droite
if ext == '.pdf':
tree.add_node(TreeViewLabelPath(os.path.join(root, fileitem), text=label), dirNodes[root])
else:
tree.add_node(TreeViewLabel(text=label, no_selection=True), dirNodes[root]) # FIXME Faire du gris
示例12: MainWindow
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
class MainWindow(BoxLayout):
def __init__(self, **kwargs):
BoxLayout.__init__(self, **kwargs)
self.nodes = []
self.tree = TreeView(hide_root=True)
# Create UI
self.add_node()
self.add_widget(self.tree)
def add_node(self):
parent_nodes = []
remove_list = []
parent_texts = []
add_list = []
add_nodes = []
# Add root node
for g in game_data:
if not g[1]:
node = self.get_node(g[0])
node.is_open = True
self.tree.add_node(node)
parent_nodes.append(node)
remove_list.append(g)
parent_texts.append(g[0])
# Remove parents level 1
for rm in remove_list:
print('remove ', rm[0])
game_data.remove(rm)
remove_list = []
c = 0
while game_data and c < 5:
print('data is ', game_data)
for index, g in enumerate(game_data):
if g[1] in parent_texts:
print(g[0], ' is child of ', parent_texts)
add_list.append(g)
parent_texts = []
for p in parent_nodes:
for g in add_list:
if g[1] == p.text:
node = self.get_node(g[0])
self.tree.add_node(node, parent=p)
add_nodes.append(node)
parent_texts.append(g[0])
remove_list.append(g)
# Clear list
parent_nodes = add_nodes
add_nodes = []
print(parent_nodes)
# Remove
for rm in remove_list:
game_data.remove(rm)
remove_list = []
c += 1
@staticmethod
def get_node(text):
img = Image(source='C:\\Users\\PredatorPy\\Pictures\\Wallpaper\\eun-jin-dia.jpg', size_hint_x=0.1)
node = None
if text:
node = MyNode(img, text)
return node
def cb(self, e, e2, e3):
print('cb', e, e2, e3)
def state(self, e):
print(e)
def on_touch_up(self, t):
pass
示例13: MainScreen
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
class MainScreen(Screen):
file_view = ObjectProperty(None)
Builder.load_file('gui/mainscreen.kv')
stop = threading.Event()
def setup_cloud_task(self):
try:
controller.setup_cloud(AES_CRYPTO)
except CloudTokenError as err:
open_popup_error('Cloud Token', err)
self.stop.set()
def on_pre_enter(self, *args):
controller.setup_stash()
# use thread for background task, use clock in a background task to access the ui
threading.Thread(target=self.setup_cloud_task).start()
file_names = controller.get_uploaded_file_names()
self.file_view = TreeView(hide_root=True, indent_level=4)
self.file_view.size_hint = 1, None
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):
#.........这里部分代码省略.........
示例14: _on_view_manager
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import add_node [as 别名]
def _on_view_manager( self ) :
"""
:return:
"""
if not self._view_manager :
self._view_manager = screen.ViewManagerScreen()
self._view_manager.name = 'screen_view_manager'
self._view_manager.id = 'view_manager_screen'
tv = TreeView( root_options=dict( text = 'king console' , font_size = 18 ) )
self._rube_widget = tv
layout = GridLayout( orientation='horizontal' , size_hint_y = None , cols=1 , size = (480 , 900 ))
# action bar
ab = Builder.load_string( self._retr_resource( 'action_bar_plus' ) )
layout.add_widget( ab )
# scroll
sv = ScrollView()
# tree view
n1 = tv.add_node(screen.TreeManagerLabel(text='main context') )
n2 = tv.add_node(screen.TreeManagerLabel(text='transport'), n1)
tv.add_node(screen.TreeManagerLabel(text='syn ack'), n2)
n3 = tv.add_node(screen.TreeManagerLabel(text='mini mport scan'), n2)
tv.add_node(screen.TreeManagerLabel(text='discovery & port manip'), n3)
tv.add_node(screen.TreeManagerLabel(text='nmap firewalk'), n3)
tv.add_node(screen.TreeManagerLabel(text='atomic firewalk'), n3)
n4 = tv.add_node(screen.TreeManagerLabel(text='network'), n1)
tv.add_node(screen.TreeManagerLabel(text='ping'), n4)
n5 = tv.add_node(screen.TreeManagerLabel(text='ping subnet'), n4)
tv.add_node(screen.TreeManagerLabel(text='beaucoup ping' ) , n5),
n6 = tv.add_node(screen.TreeManagerLabel(text='application & discovery'), n1)
n7 = tv.add_node(screen.TreeManagerLabel(text='quick fingerprint'), n6)
tv.add_node(screen.TreeManagerLabel(text='fat ingerprint'), n6)
tv.add_node(screen.TreeManagerLabel(text='baby snmp'), n7)
tv.add_node(screen.TreeManagerLabel(text='upnp'), n7)
tv.add_node(screen.TreeManagerLabel(text='ip geography'), n7)
n8 = tv.add_node(screen.TreeManagerLabel(text='datalink'), n1)
tv.add_node(screen.TreeManagerLabel(text='arp'), n8)
n9 = tv.add_node(screen.TreeManagerLabel(text='arp scan'), n8)
tv.add_node(screen.TreeManagerLabel(text='arp monitor'), n9)
n10 = tv.add_node(screen.TreeManagerLabel(text='streams'), n1)
tv.add_node(screen.TreeManagerLabel(text='payload policy'), n10)
tv.add_node(screen.TreeManagerLabel(text='traceroute context' ) )
tv.add_node(screen.TreeManagerLabel(text='packet stream context' ) )
layout.add_widget( tv )
sv.add_widget( layout )
self._view_manager.add_widget( sv )
self.root.add_widget( self._view_manager )
self.root.current = self._view_manager.name