本文整理汇总了Python中kivy.uix.treeview.TreeView.toggle_node方法的典型用法代码示例。如果您正苦于以下问题:Python TreeView.toggle_node方法的具体用法?Python TreeView.toggle_node怎么用?Python TreeView.toggle_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.treeview.TreeView
的用法示例。
在下文中一共展示了TreeView.toggle_node方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: POSFMApp
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import toggle_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)