bugfix: examples working in PyQt 4.9.6 (workaround for API change)

This commit is contained in:
Luke Campagnola 2013-03-04 23:29:22 -05:00
parent dd3603dc58
commit 262d4bf53f

View File

@ -96,6 +96,7 @@ class ExampleLoader(QtGui.QMainWindow):
self.codeBtn.hide() self.codeBtn.hide()
global examples global examples
self.itemCache = []
self.populateTree(self.ui.exampleTree.invisibleRootItem(), examples) self.populateTree(self.ui.exampleTree.invisibleRootItem(), examples)
self.ui.exampleTree.expandAll() self.ui.exampleTree.expandAll()
@ -122,6 +123,9 @@ class ExampleLoader(QtGui.QMainWindow):
def populateTree(self, root, examples): def populateTree(self, root, examples):
for key, val in examples.items(): for key, val in examples.items():
item = QtGui.QTreeWidgetItem([key]) item = QtGui.QTreeWidgetItem([key])
self.itemCache.append(item) # PyQt 4.9.6 no longer keeps references to these wrappers,
# so we need to make an explicit reference or else the .file
# attribute will disappear.
if isinstance(val, basestring): if isinstance(val, basestring):
item.file = val item.file = val
else: else: