mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[pyqgis-console] fix object inspector on windows 7
- minor fixes
This commit is contained in:
parent
345a0aef87
commit
5cbf42b084
@ -605,7 +605,7 @@ class EditorTabWidget(QTabWidget):
|
||||
self.topFrame.show()
|
||||
else:
|
||||
self.newTabEditor(filename=None)
|
||||
|
||||
|
||||
## Fixes #7653
|
||||
if sys.platform != 'darwin':
|
||||
self.setDocumentMode(True)
|
||||
@ -732,7 +732,12 @@ class EditorTabWidget(QTabWidget):
|
||||
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)
|
||||
|
||||
@ -762,8 +767,10 @@ class EditorTabWidget(QTabWidget):
|
||||
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 = {}
|
||||
@ -771,7 +778,7 @@ class EditorTabWidget(QTabWidget):
|
||||
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
|
||||
@ -788,31 +795,39 @@ class EditorTabWidget(QTabWidget):
|
||||
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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user