def getTreeInfo(componentName): c = getComponent(componentName) treeNodes = getContent(componentName) model = c.getModel() tree = swing.JTree(model) treeList = [] treeStructList = [] for i in range(len(treeNodes[0])): treeStruct = c.getPathForRow(i) Strg = treeStruct if type(treeStruct) != type(None): Strg = string.replace(str(treeStruct)[1:-1], ", ", "/") treeStructList.append(Strg) for i in range(len(treeNodes[0])): tree.expandRow(i) treeStruct = tree.getPathForRow(i) Strg = string.replace(str(treeStruct)[1:-1], ", ", "/") if Strg in treeStructList: Strg = '/' + Strg treeList.append(Strg) return treeList
seqRoot = Node(seq.getId()) treeRoot.add(seqRoot) for ix in range(lattice.len()): el = lattice.getItem(ix) pos = el.getPosition() length = el.getLength() strt_pos = el.getAbsPosition() - length * 0.5 label = "s=" + repr(strt_pos) + " m," label += " l=" + repr(length) + " m," label += " p=" + repr(pos) + " m" leave = Node(label) branch = Node(el.getName()) branch.add(leave) seqRoot.add(branch) return treeRoot #................................................................... if __name__ == '__main__': #print "processing: jython",sys.argv[0] acc = getAccelerator() tree1 = makeXALTree('XAL Sequences & Nodes', acc) tree2 = makeLatticeTree('Lattice Trees', acc) pane1 = swing.JScrollPane(swing.JTree(tree1)) pane2 = swing.JScrollPane(swing.JTree(tree2)) main = swing.Box.createHorizontalBox() main.add(pane1) main.add(pane2) swing.test(main, (900, 500), sys.argv[0])
for child in self.getChildren(): if child == node: return index index = index+1 return -1 def getParent(self): return self.myparent def toString(self): return self.name+' = '+shortrepr(self.object) if __name__ == '__main__': class foo: bar = 99 eggs = 'hello' class baz: x, y, z = 1, 2, 3 func = range import __main__ f = foo() f.pyfunc = mydir root = ObjectNode(None, 'foo', __main__) tree = swing.JTree(root) swing.test(swing.JScrollPane(tree))
'ThreadState': None, } from pawt import swing Node = swing.tree.DefaultMutableTreeNode def addNode(tree, key, value): node = Node(key) tree.add(node) if value is not None: addLeaves(node, value.items()) def addLeaves(node, items): items.sort() for key, value in items: addNode(node, key, value) def makeTree(name, data): tree = Node('A Few JPython Classes') addLeaves(tree, data.items()) return tree if __name__ == '__main__': tree = makeTree('Some JPython Classes', data) swing.test(swing.JScrollPane(swing.JTree(tree)))
def makeTree(name, data): tree = Node("Sample Tree") addLeaves(tree, data.items()) return swing.JTree(tree)