child2.set_has_children() def expand_item(event): "lazy evaluation example: virtually add children at runtime" if not event.detail.get_children_count(): for i in range(5): it = tv.items.add(parent=event.detail, text="lazy child %s" % i) it.set_has_children() # allow to lazy expand this child too # assign some event handlers: tv.onitemexpanding = expand_item tv.onitemselected = "print 'selected TreeItem:', event.detail.text" w.show() # basic tests: # iterate on the root node: for i, nodx in enumerate(root): assert nodx.text == "Child %s" % (i + 1) nodx.text = "hello %s" % i assert nodx.text == "hello %s" % i if i == 0: assert nodx.get_children_count() == 1 assert root.get_children_count() == 4 from gui.tools.inspector import InspectorTool InspectorTool().show(w) app.MainLoop()
def inspect(obj): "Open the inspector windows for a given object" from gui.tools.inspector import InspectorTool inspector = InspectorTool() inspector.show(obj) return inspector