diff -r 9aad21c7765d -r 5e6792b85a8a eric6/UI/PythonDisViewer.py --- a/eric6/UI/PythonDisViewer.py Tue Sep 22 19:30:03 2020 +0200 +++ b/eric6/UI/PythonDisViewer.py Wed Sep 23 19:10:42 2020 +0200 @@ -20,6 +20,8 @@ QApplication, QTreeWidgetItem, QAbstractItemView, QWidget, QMenu ) +from E5Gui.E5Application import e5App + import Preferences from .Ui_PythonDisViewer import Ui_PythonDisViewer @@ -83,6 +85,9 @@ self.tr('Expand All'), self.__expandAllDis) self.__disMenu.addAction( self.tr('Collapse All'), self.__collapseAllDis) + self.__disMenu.addSeparator() + self.__disMenu.addAction( + self.tr('Configure...'), self.__configure) self.__codeInfoMenu = QMenu(self.codeInfoWidget) if self.__mode == PythonDisViewerModes.SourceDisassemblyMode: @@ -92,6 +97,9 @@ self.tr('Expand All'), self.__expandAllCodeInfo) self.__codeInfoMenu.addAction( self.tr('Collapse All'), self.__collapseAllCodeInfo) + self.__codeInfoMenu.addSeparator() + self.__codeInfoMenu.addAction( + self.tr('Configure...'), self.__configure) self.__errorColor = QBrush( Preferences.getPython("DisViewerErrorColor")) @@ -100,7 +108,11 @@ self.__jumpTargetColor = QBrush( Preferences.getPython("DisViewerLabeledColor")) - self.disWidget.itemClicked.connect(self.__disItemClicked) + self.__showCodeInfoDetails = Preferences.getPython( + "DisViewerExpandCodeInfoDetails") + + if self.__mode == PythonDisViewerModes.SourceDisassemblyMode: + self.disWidget.itemClicked.connect(self.__disItemClicked) self.disWidget.itemCollapsed.connect(self.__resizeDisColumns) self.disWidget.itemExpanded.connect(self.__resizeDisColumns) self.disWidget.customContextMenuRequested.connect( @@ -116,7 +128,6 @@ self.__disViewerStateChanged) self.codeInfoWidget.hide() - self.hide() elif self.__mode == PythonDisViewerModes.TracebackMode: @@ -408,17 +419,18 @@ return { "name": co.co_name, "filename": co.co_filename, + "firstlineno": co.co_firstlineno, "argcount": co.co_argcount, "posonlyargcount": co.co_posonlyargcount, "kwonlyargcount": co.co_kwonlyargcount, "nlocals": co.co_nlocals, "stacksize": co.co_stacksize, "flags": dis.pretty_flags(co.co_flags), - "consts": co.co_consts, - "names": co.co_names, - "varnames": co.co_varnames, - "freevars": co.co_freevars, - "cellvars": co.co_cellvars, + "consts": [str(const) for const in co.co_consts], + "names": [str(name) for name in co.co_names], + "varnames": [str(name) for name in co.co_varnames], + "freevars": [str(var) for var in co.co_freevars], + "cellvars": [str(var) for var in co.co_cellvars], } def __loadDIS(self): @@ -436,8 +448,9 @@ )) return - self.disWidget.clear() + self.clear() self.__editor.clearAllHighlights() + self.codeInfoWidget.hide() source = self.__editor.text() if not source.strip(): @@ -541,8 +554,8 @@ lastInstructions[0], QAbstractItemView.PositionAtCenter) - if "codeInfo" in disassembly: - self.__showCodeInfoData(disassembly["codeInfo"]) + if "codeinfo" in disassembly: + self.__showCodeInfoData(disassembly["codeinfo"]) def __resizeDisColumns(self): """ @@ -625,7 +638,6 @@ @param column column number of the click @type int """ - # TODO: add code to deal with Traceback mode self.__editor.clearAllHighlights() if itm is not None: @@ -713,6 +725,9 @@ self.__jumpTargetColor = QBrush( Preferences.getPython("DisViewerLabeledColor")) + self.__showCodeInfoDetails = Preferences.getPython( + "DisViewerExpandCodeInfoDetails") + if self.isVisible(): self.__loadDIS() @@ -748,6 +763,7 @@ Public method to clear the display. """ self.disWidget.clear() + self.codeInfoWidget.clear() def __showCodeInfo(self): """ @@ -777,8 +793,7 @@ """ parent = QTreeWidgetItem(self.codeInfoWidget, [title, str(len(infoList))]) - # TODO: make this a configuration item - parent.setExpanded(False) + parent.setExpanded(self.__showCodeInfoDetails) for index, value in enumerate(infoList): itm = QTreeWidgetItem(parent, [str(index), str(value)]) @@ -792,6 +807,8 @@ QTreeWidgetItem(self.codeInfoWidget, [ self.tr("Filename"), codeInfo["filename"]]) QTreeWidgetItem(self.codeInfoWidget, [ + self.tr("First Line"), str(codeInfo["firstlineno"])]) + QTreeWidgetItem(self.codeInfoWidget, [ self.tr("Argument Count"), str(codeInfo["argcount"])]) QTreeWidgetItem(self.codeInfoWidget, [ self.tr("Positional-only Arguments"), @@ -860,3 +877,10 @@ # don't show context menu on empty list coord = self.codeInfoWidget.mapToGlobal(coord) self.__codeInfoMenu.popup(coord) + + def __configure(self): + """ + Private method to open the configuration dialog. + """ + e5App().getObject("UserInterface").showPreferences( + "pythonPage")