comparison python/astviewer.py @ 164:e023d3ce1d63

Fix to loc of assignment
author Windel Bouwman
date Mon, 18 Mar 2013 22:15:57 +0100
parents 5a965e9664f2
children 598d3888a11c
comparison
equal deleted inserted replaced
163:8104fc8b5e90 164:e023d3ce1d63
1 from PyQt4.QtCore import * 1 from PyQt4.QtCore import *
2 from PyQt4.QtGui import * 2 from PyQt4.QtGui import *
3 from c3 import Visitor
3 4
4 def astToNamedElement(astNode, parentNode): 5 def astToNamedElement(astNode, parentNode):
5 """ Helper to convert and AST tree to NamedElement tree: """ 6 """ Helper to convert and AST tree to NamedElement tree: """
6 item = QStandardItem(str(astNode)) 7 item = QStandardItem(str(astNode))
7 item.setData(astNode) 8 item.setData(astNode)
18 self.clicked.connect(self.selectHandler) 19 self.clicked.connect(self.selectHandler)
19 20
20 def setAst(self, ast): 21 def setAst(self, ast):
21 """ Create a new model and add all ast elements to it """ 22 """ Create a new model and add all ast elements to it """
22 model = QStandardItemModel() 23 model = QStandardItemModel()
24 print(ast)
23 if ast: 25 if ast:
24 astToNamedElement(ast, model.invisibleRootItem()) 26 astToNamedElement(ast, model.invisibleRootItem())
25 self.setModel( model ) 27 self.setModel(model)
26 self.expandAll() 28 self.expandAll()
27 29
28 def selectHandler(self, index): 30 def selectHandler(self, index):
29 if not index.isValid(): 31 if not index.isValid():
30 return 32 return