本文整理汇总了Python中kivy.uix.treeview.TreeView.size_hint_y方法的典型用法代码示例。如果您正苦于以下问题:Python TreeView.size_hint_y方法的具体用法?Python TreeView.size_hint_y怎么用?Python TreeView.size_hint_y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.treeview.TreeView
的用法示例。
在下文中一共展示了TreeView.size_hint_y方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_scrollable_treeview
# 需要导入模块: from kivy.uix.treeview import TreeView [as 别名]
# 或者: from kivy.uix.treeview.TreeView import size_hint_y [as 别名]
def create_scrollable_treeview(nested_dicts, onclick, root_label):
tv = TreeView(root_options={'text': root_label})
def populate_tree(parent, level, index, path):
obj = level if index is None else level[index]
if hasattr(obj, 'name'):
label = TreeViewLabel(text=obj.name,
onclick=onclick)
label.path = copy(path)
tv.add_node(label, parent)
else:
try:
indices = obj.iterkeys()
except AttributeError:
indices = xrange(len(obj))
# This `if` is a hack to deal with the root of the given tree
if index is None:
group_node = None
else:
group_node = TreeViewLabel(text=index)
tv.add_node(group_node, parent)
for index in indices:
populate_tree(group_node, obj, index, path + [index])
populate_tree(None, nested_dicts, None, [])
# Make the tree scrollable inside the ScrollView
tv.size_hint_y = None
tv.bind(minimum_height=tv.setter('height'))
scrollable = ScrollView()
scrollable.add_widget(tv)
return scrollable