Skip to content

Commit

Permalink
[pyqgis-console] fix object inspector on windows 7
Browse files Browse the repository at this point in the history
- minor fixes
  • Loading branch information
slarosa committed Apr 25, 2013
1 parent 345a0ae commit 5cbf42b
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions python/console/console_editor.py
Expand Up @@ -605,7 +605,7 @@ def __init__(self, parent):
self.topFrame.show()
else:
self.newTabEditor(filename=None)

## Fixes #7653
if sys.platform != 'darwin':
self.setDocumentMode(True)
Expand Down Expand Up @@ -732,7 +732,12 @@ def restoreTabs(self):
tabName = pathFile.split('/')[-1]
self.newTabEditor(tabName, pathFile)
else:
self.newTabEditor(filename=None)
print '## Error: '
s = 'Unable to restore the file: \n%s\n' % pathFile
sys.stderr.write(s)
self.parent.updateTabListScript(pathFile)
if self.count() < 1:
self.newTabEditor(filename=None)
self.topFrame.close()
self.enableToolBarEditor(True)

Expand Down Expand Up @@ -762,16 +767,18 @@ def listObject(self, tab):
if tabWidget.path:
pathFile, file = os.path.split(unicode(tabWidget.path))
module, ext = os.path.splitext(file)
found = False
if pathFile not in sys.path:
sys.path.append(pathFile)
found = True
try:
reload(pyclbr)
dictObject = {}
superClassName = []
readModule = pyclbr.readmodule(module)
readModuleFunction = pyclbr.readmodule_ex(module)
for name, class_data in sorted(readModule.items(), key=lambda x:x[1].lineno):
if class_data.file == tabWidget.path:
if os.path.normpath(str(class_data.file)) == os.path.normpath(str(tabWidget.path)):
for superClass in class_data.super:
if superClass == 'object':
continue
Expand All @@ -788,31 +795,39 @@ def listObject(self, tab):
classItem.setText(0, name)
classItem.setToolTip(0, name)
classItem.setText(1, str(class_data.lineno))
classItem.setIcon(0, QgsApplication.getThemeIcon("console/iconClassTreeWidgetConsole.png"))
iconClass = QgsApplication.getThemeIcon("console/iconClassTreeWidgetConsole.png")
classItem.setIcon(0, iconClass)
dictObject[name] = class_data.lineno
for meth, lineno in sorted(class_data.methods.items(), key=itemgetter(1)):
methodItem = QTreeWidgetItem()
methodItem.setText(0, meth + ' ')
methodItem.setText(1, str(lineno))
methodItem.setToolTip(0, meth)
methodItem.setIcon(0, QgsApplication.getThemeIcon("console/iconMethodTreeWidgetConsole.png"))
iconMeth = QgsApplication.getThemeIcon("console/iconMethodTreeWidgetConsole.png")
methodItem.setIcon(0, iconMeth)
classItem.addChild(methodItem)
dictObject[meth] = lineno
# if found:
# sys.path.remove(os.path.split(unicode(str(class_data.file)))[0])
self.parent.listClassMethod.addTopLevelItem(classItem)
for func_name, data in sorted(readModuleFunction.items(), key=lambda x:x[1].lineno):
if isinstance(data, pyclbr.Function) and data.file == tabWidget.path:
if isinstance(data, pyclbr.Function) and \
os.path.normpath(str(data.file)) == os.path.normpath(str(tabWidget.path)):
funcItem = QTreeWidgetItem()
funcItem.setText(0, func_name + ' ')
funcItem.setText(1, str(data.lineno))
funcItem.setToolTip(0, func_name)
funcItem.setIcon(0, QgsApplication.getThemeIcon("console/iconFunctionTreeWidgetConsole.png"))
iconFunc = QgsApplication.getThemeIcon("console/iconFunctionTreeWidgetConsole.png")
funcItem.setIcon(0, iconFunc)
dictObject[func_name] = data.lineno
self.parent.listClassMethod.addTopLevelItem(funcItem)
if found:
sys.path.remove(pathFile)
except:
s = traceback.format_exc()
print '## Error: '
sys.stderr.write(s)

def changeFont(self):
countTab = self.count()
for i in range(countTab):
Expand Down

0 comments on commit 5cbf42b

Please sign in to comment.