eric6/UI/PythonDisViewer.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7771
diff changeset
3 # Copyright (c) 2020 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a widget to visualize the Python Disassembly for some
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 Python sources.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import os
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import dis
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
14 import enum
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
15
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
16
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from PyQt5.QtCore import pyqtSlot, Qt, QTimer
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
18 from PyQt5.QtGui import QBrush
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from PyQt5.QtWidgets import (
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
20 QTreeWidgetItem, QAbstractItemView, QWidget, QMenu
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 )
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
23 from E5Gui.E5Application import e5App
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
24 from E5Gui.E5OverrideCursor import E5OverrideCursor
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
25
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
26 import Preferences
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
27
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
28 from .Ui_PythonDisViewer import Ui_PythonDisViewer
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
29
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
31 class PythonDisViewerModes(enum.Enum):
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
32 """
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
33 Class implementing the disassembly viewer operation modes.
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
34 """
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
35 SourceDisassemblyMode = 0
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
36 TracebackMode = 1
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
37
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
38
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
39 class PythonDisViewer(QWidget, Ui_PythonDisViewer):
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 Class implementing a widget to visualize the Python Disassembly for some
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 Python sources.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 StartLineRole = Qt.UserRole
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 EndLineRole = Qt.UserRole + 1
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
46 CodeInfoRole = Qt.UserRole + 2
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
48 def __init__(self, viewmanager,
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
49 mode=PythonDisViewerModes.SourceDisassemblyMode,
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
50 parent=None):
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 Constructor
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 @param viewmanager reference to the viewmanager object
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @type ViewManager
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
56 @param mode operation mode of the viewer
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
57 @type int
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @param parent reference to the parent widget
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 @type QWidget
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 super(PythonDisViewer, self).__init__(parent)
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
62 self.setupUi(self)
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
64 self.setWindowTitle(self.tr("Disassembly"))
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
65
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.__vm = viewmanager
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.__vmConnected = False
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
69 self.__mode = mode
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
70
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.__editor = None
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__source = ""
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
74 self.disWidget.setHeaderLabels(
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 [self.tr("Line"), self.tr("Offset"), self.tr("Operation"),
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.tr("Parameters"), self.tr("Interpreted Parameters")])
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
77 self.codeInfoWidget.setHeaderLabels(
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
78 [self.tr("Key"), self.tr("Value")])
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
80 self.__disMenu = QMenu(self.disWidget)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
81 if self.__mode == PythonDisViewerModes.SourceDisassemblyMode:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
82 self.__codeInfoAct = self.__disMenu.addAction(
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
83 self.tr("Show Code Info"), self.__showCodeInfo)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
84 self.__disMenu.addSeparator()
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
85 self.__disMenu.addAction(
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
86 self.tr('Expand All'), self.__expandAllDis)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
87 self.__disMenu.addAction(
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
88 self.tr('Collapse All'), self.__collapseAllDis)
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
89 self.__disMenu.addSeparator()
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
90 self.__disMenu.addAction(
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
91 self.tr('Configure...'), self.__configure)
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
92
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
93 self.__codeInfoMenu = QMenu(self.codeInfoWidget)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
94 if self.__mode == PythonDisViewerModes.SourceDisassemblyMode:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
95 self.__codeInfoMenu.addAction(
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
96 self.tr("Hide"), self.codeInfoWidget.hide)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
97 self.__codeInfoMenu.addAction(
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
98 self.tr('Expand All'), self.__expandAllCodeInfo)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
99 self.__codeInfoMenu.addAction(
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
100 self.tr('Collapse All'), self.__collapseAllCodeInfo)
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
101 self.__codeInfoMenu.addSeparator()
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
102 self.__codeInfoMenu.addAction(
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
103 self.tr('Configure...'), self.__configure)
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
104
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
105 self.__errorColor = QBrush(
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
106 Preferences.getPython("DisViewerErrorColor"))
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
107 self.__currentInstructionColor = QBrush(
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
108 Preferences.getPython("DisViewerCurrentColor"))
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
109 self.__jumpTargetColor = QBrush(
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
110 Preferences.getPython("DisViewerLabeledColor"))
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
111
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
112 self.__showCodeInfoDetails = Preferences.getPython(
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
113 "DisViewerExpandCodeInfoDetails")
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
114
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
115 if self.__mode == PythonDisViewerModes.SourceDisassemblyMode:
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
116 self.disWidget.itemClicked.connect(self.__disItemClicked)
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
117 self.disWidget.itemCollapsed.connect(self.__resizeDisColumns)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
118 self.disWidget.itemExpanded.connect(self.__resizeDisColumns)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
119 self.disWidget.customContextMenuRequested.connect(
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
120 self.__disContextMenuRequested)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
121
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
122 self.codeInfoWidget.itemCollapsed.connect(self.__resizeCodeInfoColumns)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
123 self.codeInfoWidget.itemExpanded.connect(self.__resizeCodeInfoColumns)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
124 self.codeInfoWidget.customContextMenuRequested.connect(
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
125 self.__codeInfoContextMenuRequested)
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
127 if self.__mode == PythonDisViewerModes.SourceDisassemblyMode:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
128 self.__vm.disViewerStateChanged.connect(
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
129 self.__disViewerStateChanged)
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
130
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
131 self.codeInfoWidget.hide()
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
132 self.hide()
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
133
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
134 elif self.__mode == PythonDisViewerModes.TracebackMode:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
135 self.__styleLabels()
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
137 def __disContextMenuRequested(self, coord):
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
138 """
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
139 Private slot to show the context menu of the disassembly widget.
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
140
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
141 @param coord position of the mouse pointer
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
142 @type QPoint
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
143 """
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
144 if self.__mode == PythonDisViewerModes.SourceDisassemblyMode:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
145 itm = self.disWidget.itemAt(coord)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
146 self.__codeInfoAct.setEnabled(bool(itm.data(0, self.CodeInfoRole)))
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
147 self.disWidget.setCurrentItem(itm)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
148
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
149 if self.disWidget.topLevelItemCount() > 0:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
150 # don't show context menu on empty list
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
151 coord = self.disWidget.mapToGlobal(coord)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
152 self.__disMenu.popup(coord)
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
153
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 def __editorChanged(self, editor):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 Private slot to handle a change of the current editor.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 @param editor reference to the current editor
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 @type Editor
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 if editor is not self.__editor:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 if self.__editor:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 self.__editor.clearAllHighlights()
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 self.__editor = editor
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 if self.__editor:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 self.__loadDIS()
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 def __editorSaved(self, editor):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 Private slot to reload the Disassembly after the connected editor was
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 saved.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 @param editor reference to the editor that performed a save action
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 @type Editor
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 if editor and editor is self.__editor:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 self.__loadDIS()
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
179 def __editorLineChanged(self, editor, lineno):
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 Private slot to handle a mouse button double click in the editor.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 @param editor reference to the editor, that emitted the signal
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 @type Editor
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
185 @param lineno line number of the editor's cursor (zero based)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
186 @type int
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 """
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
188 if editor is self.__editor:
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 if editor.isModified():
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 # reload the source
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 QTimer.singleShot(0, self.__loadDIS)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 # highlight the corresponding entry
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
194 QTimer.singleShot(0, self.__selectItemForEditorLine)
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
196 def __editorLanguageChanged(self, editor):
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
197 """
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
198 Private slot to handle a change of the editor language.
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
199
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
200 @param editor reference to the editor which changed language
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
201 @type Editor
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
202 """
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
203 if editor is self.__editor:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
204 QTimer.singleShot(0, self.__loadDIS)
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
205
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 def __lastEditorClosed(self):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 Private slot to handle the last editor closed signal of the view
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 manager.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 self.hide()
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 def show(self):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 Public slot to show the DIS viewer.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 super(PythonDisViewer, self).show()
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
219 if (
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
220 self.__mode == PythonDisViewerModes.SourceDisassemblyMode and
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
221 not self.__vmConnected
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
222 ):
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 self.__vm.editorChangedEd.connect(self.__editorChanged)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 self.__vm.editorSavedEd.connect(self.__editorSaved)
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
225 self.__vm.editorLineChangedEd.connect(self.__editorLineChanged)
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
226 self.__vm.editorLanguageChanged.connect(
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
227 self.__editorLanguageChanged)
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 self.__vmConnected = True
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
229
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
230 self.__styleLabels()
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 def hide(self):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 Public slot to hide the DIS viewer.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 super(PythonDisViewer, self).hide()
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 if self.__editor:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 self.__editor.clearAllHighlights()
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
241 if (
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
242 self.__mode == PythonDisViewerModes.SourceDisassemblyMode and
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
243 self.__vmConnected
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
244 ):
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 self.__vm.editorChangedEd.disconnect(self.__editorChanged)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 self.__vm.editorSavedEd.disconnect(self.__editorSaved)
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
247 self.__vm.editorLineChangedEd.disconnect(self.__editorLineChanged)
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
248 self.__vm.editorLanguageChanged.disconnect(
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
249 self.__editorLanguageChanged)
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 self.__vmConnected = False
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 def shutdown(self):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 Public method to perform shutdown actions.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 self.__editor = None
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 def __disViewerStateChanged(self, on):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 Private slot to toggle the display of the Disassembly viewer.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 @param on flag indicating to show the Disassembly
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 @type bool
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 """
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
265 if self.__mode == PythonDisViewerModes.SourceDisassemblyMode:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
266 editor = self.__vm.activeWindow()
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
267 if on:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
268 if editor is not self.__editor:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
269 self.__editor = editor
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
270 self.show()
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
271 self.__loadDIS()
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
272 else:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
273 self.hide()
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
274 self.__editor = None
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
276 def __expandAllDis(self):
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
277 """
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
278 Private slot to expand all items of the disassembly widget.
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
279 """
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
280 block = self.disWidget.blockSignals(True)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
281 self.disWidget.expandAll()
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
282 self.disWidget.blockSignals(block)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
283 self.__resizeDisColumns()
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
284
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
285 def __collapseAllDis(self):
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
286 """
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
287 Private slot to collapse all items of the disassembly widget.
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
288 """
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
289 block = self.disWidget.blockSignals(True)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
290 self.disWidget.collapseAll()
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
291 self.disWidget.blockSignals(block)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
292 self.__resizeDisColumns()
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
293
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 def __createErrorItem(self, error):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 Private method to create a top level error item.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 @param error error message
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 @type str
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 @return generated item
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 @rtype QTreeWidgetItem
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 """
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
303 itm = QTreeWidgetItem(self.disWidget, [error])
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 itm.setFirstColumnSpanned(True)
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
305 itm.setForeground(0, self.__errorColor)
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 return itm
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
308 def __createTitleItem(self, title, line, parentItem):
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 Private method to create a title item.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 @param title titel string for the item
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 @type str
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 @param line start line of the titled disassembly
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 @type int
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
316 @param parentItem reference to the parent item
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
317 @type QTreeWidget or QTreeWidgetItem
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 @return generated item
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 @rtype QTreeWidgetItem
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 """
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
321 itm = QTreeWidgetItem(parentItem, [title])
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 itm.setFirstColumnSpanned(True)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 itm.setExpanded(True)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 itm.setData(0, self.StartLineRole, line)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 itm.setData(0, self.EndLineRole, line)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 return itm
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 def __createInstructionItem(self, instr, parent, lasti=-1):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 Private method to create an item for the given instruction.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 @param instr instruction the item should be based on
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 @type dis.Instruction
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 @param parent reference to the parent item
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 @type QTreeWidgetItem
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 @param lasti index of the instruction of a traceback
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 @type int
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 @return generated item
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 @rtype QTreeWidgetItem
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 fields = []
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 # Column: Source code line number (right aligned)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 if instr.starts_line:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 fields.append("{0:d}".format(instr.starts_line))
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 else:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 fields.append("")
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 # Column: Instruction offset from start of code sequence
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 # (right aligned)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 fields.append("{0:d}".format(instr.offset))
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 # Column: Opcode name
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 fields.append(instr.opname)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 # Column: Opcode argument (right aligned)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 if instr.arg is not None:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 fields.append(repr(instr.arg))
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 # Column: Opcode argument details
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 if instr.argrepr:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 fields.append('(' + instr.argrepr + ')')
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 itm = QTreeWidgetItem(parent, fields)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 for col in (0, 1, 3):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 itm.setTextAlignment(col, Qt.AlignRight)
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
364 # set font to indicate current instruction and jump target
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 font = itm.font(0)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 if instr.offset == lasti:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 font.setItalic(True)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 if instr.is_jump_target:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 font.setBold(True)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 for col in range(itm.columnCount()):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 itm.setFont(col, font)
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
372 # set color to indicate current instruction or jump target
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
373 if instr.offset == lasti:
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
374 foreground = self.__currentInstructionColor
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
375 elif instr.is_jump_target:
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
376 foreground = self.__jumpTargetColor
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
377 else:
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
378 foreground = None
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
379 if foreground:
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
380 for col in range(itm.columnCount()):
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
381 itm.setForeground(col, foreground)
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 itm.setExpanded(True)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 if instr.starts_line:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 itm.setData(0, self.StartLineRole, instr.starts_line)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 itm.setData(0, self.EndLineRole, instr.starts_line)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 else:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 # get line from parent (= start line)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 lineno = parent.data(0, self.StartLineRole)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 itm.setData(0, self.StartLineRole, lineno)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 itm.setData(0, self.EndLineRole, lineno)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 return itm
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 def __updateItemEndLine(self, itm):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 Private method to update an items end line based on its children.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 @param itm reference to the item to be updated
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 @type QTreeWidgetItem
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 if itm.childCount():
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 endLine = max(
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 itm.child(index).data(0, self.EndLineRole)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 for index in range(itm.childCount())
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 )
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 else:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 endLine = itm.data(0, self.StartLineRole)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 itm.setData(0, self.EndLineRole, endLine)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
411 def __createCodeInfo(self, co):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
412 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
413 Private method to create a dictionary containing the code info data.
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
414
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
415 @param co reference to the code object to generate the info for
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
416 @type code
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
417 @return dictionary containing the code info data
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
418 @rtype dict
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
419 """
7714
79bde78e3e16 PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7712
diff changeset
420 codeInfoDict = {
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
421 "name": co.co_name,
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
422 "filename": co.co_filename,
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
423 "firstlineno": co.co_firstlineno,
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
424 "argcount": co.co_argcount,
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
425 "kwonlyargcount": co.co_kwonlyargcount,
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
426 "nlocals": co.co_nlocals,
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
427 "stacksize": co.co_stacksize,
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
428 "flags": dis.pretty_flags(co.co_flags),
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
429 "consts": [str(const) for const in co.co_consts],
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
430 "names": [str(name) for name in co.co_names],
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
431 "varnames": [str(name) for name in co.co_varnames],
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
432 "freevars": [str(var) for var in co.co_freevars],
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
433 "cellvars": [str(var) for var in co.co_cellvars],
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
434 }
7714
79bde78e3e16 PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7712
diff changeset
435 try:
79bde78e3e16 PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7712
diff changeset
436 codeInfoDict["posonlyargcount"] = co.co_posonlyargcount
79bde78e3e16 PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7712
diff changeset
437 except AttributeError:
79bde78e3e16 PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7712
diff changeset
438 # does not exist prior to 3.8.0
79bde78e3e16 PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7712
diff changeset
439 codeInfoDict["posonlyargcount"] = 0
7732
4c9cf117acf6 Fixed some code style issues and one coding issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7714
diff changeset
440
4c9cf117acf6 Fixed some code style issues and one coding issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7714
diff changeset
441 return codeInfoDict
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
442
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 def __loadDIS(self):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 Private method to generate the Disassembly from the source of the
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 current editor and visualize it.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 """
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
448 if self.__mode != PythonDisViewerModes.SourceDisassemblyMode:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
449 # wrong mode, just return
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
450 return
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
451
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 if not self.__editor:
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
453 self.__createErrorItem(self.tr(
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
454 "No editor has been opened."
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
455 ))
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 return
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
458 self.clear()
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 self.__editor.clearAllHighlights()
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
460 self.codeInfoWidget.hide()
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
462 source = self.__editor.text()
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
463 if not source.strip():
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
464 # empty editor or white space only
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 self.__createErrorItem(self.tr(
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
466 "The current editor does not contain any source code."
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 ))
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 return
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
470 if not self.__editor.isPyFile():
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
471 self.__createErrorItem(self.tr(
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
472 "The current editor does not contain Python source code."
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
473 ))
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 return
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 filename = self.__editor.getFileName()
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
477 if filename:
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
478 filename = os.path.basename(filename)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
479 else:
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 filename = "<dis>"
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
482 with E5OverrideCursor():
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
483 try:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
484 codeObject = self.__tryCompile(source, filename)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
485 except Exception as exc:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
486 codeObject = None
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
487 self.__createErrorItem(str(exc))
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
489 if codeObject:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
490 self.setUpdatesEnabled(False)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
491 block = self.disWidget.blockSignals(True)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
492
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
493 self.__disassembleObject(codeObject, self.disWidget, filename)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
494 QTimer.singleShot(0, self.__resizeDisColumns)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
495
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
496 self.disWidget.blockSignals(block)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7732
diff changeset
497 self.setUpdatesEnabled(True)
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
498
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
499 @pyqtSlot(dict)
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
500 def showDisassembly(self, disassembly):
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
501 """
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
502 Public slot to receive a code disassembly from the debug client.
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
504 @param disassembly dictionary containing the disassembly information
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
505 @type dict
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
506 """
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
507 if self.__mode == PythonDisViewerModes.TracebackMode:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
508 if (
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
509 disassembly and
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
510 "instructions" in disassembly and
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
511 disassembly["instructions"]
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
512 ):
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
513 self.disWidget.clear()
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
514
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
515 self.setUpdatesEnabled(False)
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
516 block = self.disWidget.blockSignals(True)
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
517
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
518 titleItem = self.__createTitleItem(
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
519 self.tr("Disassembly of last traceback"),
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
520 disassembly["firstlineno"],
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
521 self.disWidget
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
522 )
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
523
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
524 lasti = disassembly["lasti"]
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
525 lastStartItem = None
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
526 for instrDict in disassembly["instructions"]:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
527 instr = dis.Instruction(
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
528 instrDict["opname"],
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
529 0, # dummy value
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
530 instrDict["arg"],
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
531 "", # dummy value
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
532 instrDict["argrepr"],
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
533 instrDict["offset"],
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
534 instrDict["lineno"],
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
535 instrDict["isJumpTarget"],
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
536 )
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
537 if instrDict["lineno"] > 0:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
538 if lastStartItem:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
539 self.__updateItemEndLine(lastStartItem)
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
540 lastStartItem = self.__createInstructionItem(
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
541 instr, titleItem, lasti=lasti)
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
542 else:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
543 self.__createInstructionItem(
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
544 instr, lastStartItem, lasti=lasti)
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
545 if lastStartItem:
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
546 self.__updateItemEndLine(lastStartItem)
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
547
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
548 QTimer.singleShot(0, self.__resizeDisColumns)
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
549
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
550 self.disWidget.blockSignals(block)
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
551 self.setUpdatesEnabled(True)
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
552
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
553 if lasti:
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
554 lastInstructions = self.disWidget.findItems(
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
555 "{0:d}".format(lasti),
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
556 Qt.MatchFixedString | Qt.MatchRecursive, 1)
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
557 if lastInstructions:
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
558 self.disWidget.scrollToItem(
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
559 lastInstructions[0],
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
560 QAbstractItemView.PositionAtCenter)
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
561
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
562 if "codeinfo" in disassembly:
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
563 self.__showCodeInfoData(disassembly["codeinfo"])
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
565 def __resizeDisColumns(self):
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 """
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
567 Private method to resize the columns of the disassembly widget to
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
568 suitable values.
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 """
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
570 for col in range(self.disWidget.columnCount()):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
571 self.disWidget.resizeColumnToContents(col)
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 def resizeEvent(self, evt):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 Protected method to handle resize events.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 @param evt resize event
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 @type QResizeEvent
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580 # just adjust the sizes of the columns
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
581 self.__resizeDisColumns()
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
582 self.__resizeCodeInfoColumns()
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
584 def __clearSelection(self):
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
585 """
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
586 Private method to clear all selected items.
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
587 """
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
588 for itm in self.disWidget.selectedItems():
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
589 itm.setSelected(False)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
590
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
591 def __selectChildren(self, itm, lineno):
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
592 """
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
593 Private method to select children of the given item covering the given
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
594 line number.
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
595
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
596 @param itm reference to the item
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
597 @type QTreeWidgetItem
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
598 @param lineno line number to base the selection on
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
599 @type int
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
600 """
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
601 for index in range(itm.childCount()):
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
602 child = itm.child(index)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
603 if (
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
604 child.data(0, self.StartLineRole) <= lineno <=
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
605 child.data(0, self.EndLineRole)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
606 ):
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
607 child.setSelected(True)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
608 self.__selectChildren(child, lineno)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
609
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
610 if child.data(0, self.StartLineRole) == lineno:
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
611 self.disWidget.scrollToItem(
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
612 child, QAbstractItemView.PositionAtCenter)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
613
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
614 def __selectItemForEditorLine(self):
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
615 """
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
616 Private slot to select the items corresponding with the cursor line
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
617 of the current editor.
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
618 """
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
619 # step 1: clear all selected items
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
620 self.__clearSelection()
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
621
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
622 # step 2: retrieve the editor cursor line
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
623 cline, cindex = self.__editor.getCursorPosition()
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
624 # make the line numbers 1-based
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
625 cline += 1
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
626
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
627 for index in range(self.disWidget.topLevelItemCount()):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
628 itm = self.disWidget.topLevelItem(index)
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
629 if (
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
630 itm.data(0, self.StartLineRole) <= cline <=
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
631 itm.data(0, self.EndLineRole)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
632 ):
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
633 itm.setSelected(True)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
634 self.__selectChildren(itm, cline)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
635
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 @pyqtSlot(QTreeWidgetItem, int)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 def __disItemClicked(self, itm, column):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 Private slot handling a user click on a Disassembly node item.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
641 @param itm reference to the clicked item
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642 @type QTreeWidgetItem
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 @param column column number of the click
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 @type int
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646 self.__editor.clearAllHighlights()
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648 if itm is not None:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649 startLine = itm.data(0, self.StartLineRole)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650 endLine = itm.data(0, self.EndLineRole)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 self.__editor.gotoLine(startLine, firstVisible=True,
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 expand=True)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 self.__editor.setHighlight(startLine - 1, 0, endLine, -1)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 def __tryCompile(self, source, name):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 Private method to attempt to compile the given source, first as an
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 expression and then as a statement if the first approach fails.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 @param source source code string to be compiled
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 @type str
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663 @param name name of the file containing the source
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664 @type str
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 @return compiled code
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666 @rtype code object
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 try:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 c = compile(source, name, 'eval')
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 except SyntaxError:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 c = compile(source, name, 'exec')
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672 return c
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
674 def __disassembleObject(self, co, parentItem, parentName="", lasti=-1):
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
675 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676 Private method to disassemble the given code object recursively.
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
678 @param co code object to be disassembled
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
679 @type code object
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680 @param parentItem reference to the parent item
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681 @type QTreeWidget or QTreeWidgetItem
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
682 @param parentName name of the parent code object
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683 @type str
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
684 @param lasti index of the instruction of a traceback
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
685 @type int
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
686 """
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
687 if co.co_name == "<module>":
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
688 title = os.path.basename(co.co_filename)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
689 name = ""
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
690 else:
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
691 if parentName:
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
692 name = "{0}.{1}".format(parentName, co.co_name)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
693 else:
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
694 name = co.co_name
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
695 title = self.tr("Code Object '{0}'").format(name)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
696 titleItem = self.__createTitleItem(title, co.co_firstlineno,
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
697 parentItem)
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
698 codeInfo = self.__createCodeInfo(co)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
699 if codeInfo:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
700 titleItem.setData(0, self.CodeInfoRole, codeInfo)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
701
7704
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
702 lastStartItem = None
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703 for instr in dis.get_instructions(co):
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
704 if instr.starts_line:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705 if lastStartItem:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706 self.__updateItemEndLine(lastStartItem)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
707 lastStartItem = self.__createInstructionItem(
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
708 instr, titleItem, lasti=lasti)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
709 else:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
710 self.__createInstructionItem(instr, lastStartItem, lasti=lasti)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711 if lastStartItem:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
712 self.__updateItemEndLine(lastStartItem)
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 for x in co.co_consts:
9251c4dc4f7a Started to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 if hasattr(x, 'co_code'):
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
716 self.__disassembleObject(x, titleItem, parentName=name,
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
717 lasti=lasti)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
718
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
719 self.__updateItemEndLine(titleItem)
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
720
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
721 @pyqtSlot()
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
722 def preferencesChanged(self):
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
723 """
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
724 Public slot handling changes of the Disassembly viewer settings.
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
725 """
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
726 self.__errorColor = QBrush(
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
727 Preferences.getPython("DisViewerErrorColor"))
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
728 self.__currentInstructionColor = QBrush(
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
729 Preferences.getPython("DisViewerCurrentColor"))
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
730 self.__jumpTargetColor = QBrush(
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
731 Preferences.getPython("DisViewerLabeledColor"))
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
732
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
733 self.__showCodeInfoDetails = Preferences.getPython(
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
734 "DisViewerExpandCodeInfoDetails")
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
735
7705
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
736 if self.isVisible():
90a9aefd4253 Finished to implement a Python Disassembly Viewer showing the byte code generated from a Python source file loaded in an editor pane.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7704
diff changeset
737 self.__loadDIS()
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
738
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
739 self.__styleLabels()
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
740
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
741 def __styleLabels(self):
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
742 """
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
743 Private method to style the info labels iaw. selected colors.
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
744 """
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
745 # current instruction
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
746 self.currentInfoLabel.setStyleSheet(
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
747 "QLabel {{ color : {0}; }}".format(
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
748 self.__currentInstructionColor.color().name()
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
749 )
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
750 )
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
751 font = self.currentInfoLabel.font()
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
752 font.setItalic(True)
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
753 self.currentInfoLabel.setFont(font)
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
754
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
755 # labeled instruction
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
756 self.labeledInfoLabel.setStyleSheet(
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
757 "QLabel {{ color : {0}; }}".format(
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
758 self.__jumpTargetColor.color().name()
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
759 )
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
760 )
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
761 font = self.labeledInfoLabel.font()
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
762 font.setBold(True)
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
763 self.labeledInfoLabel.setFont(font)
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
764
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
765 @pyqtSlot()
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
766 def clear(self):
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
767 """
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
768 Public method to clear the display.
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7705
diff changeset
769 """
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
770 self.disWidget.clear()
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
771 self.codeInfoWidget.clear()
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
772
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
773 def __showCodeInfo(self):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
774 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
775 Private slot handling the context menu action to show code info.
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
776 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
777 itm = self.disWidget.currentItem()
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
778 codeInfo = itm.data(0, self.CodeInfoRole)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
779 if codeInfo:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
780 self.codeInfoWidget.show()
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
781 self.__showCodeInfoData(codeInfo)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
782
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
783 def __showCodeInfoData(self, codeInfo):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
784 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
785 Private method to show the passed code info data.
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
786
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
787 @param codeInfo dictionary containing the code info data
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
788 @type dict
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
789 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
790 def createCodeInfoItems(title, infoList):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
791 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
792 Function to create code info items for the given list.
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
793
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
794 @param title title string for the list
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
795 @type str
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
796 @param infoList list of info strings
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
797 @type list of str
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
798 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
799 parent = QTreeWidgetItem(self.codeInfoWidget,
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
800 [title, str(len(infoList))])
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
801 parent.setExpanded(self.__showCodeInfoDetails)
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
802
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
803 for index, value in enumerate(infoList):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
804 itm = QTreeWidgetItem(parent, [str(index), str(value)])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
805 itm.setTextAlignment(0, Qt.AlignRight)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
806
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
807 self.codeInfoWidget.clear()
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
808
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
809 if codeInfo:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
810 QTreeWidgetItem(self.codeInfoWidget, [
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
811 self.tr("Name"), codeInfo["name"]])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
812 QTreeWidgetItem(self.codeInfoWidget, [
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
813 self.tr("Filename"), codeInfo["filename"]])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
814 QTreeWidgetItem(self.codeInfoWidget, [
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
815 self.tr("First Line"), str(codeInfo["firstlineno"])])
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
816 QTreeWidgetItem(self.codeInfoWidget, [
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
817 self.tr("Argument Count"), str(codeInfo["argcount"])])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
818 QTreeWidgetItem(self.codeInfoWidget, [
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
819 self.tr("Positional-only Arguments"),
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
820 str(codeInfo["posonlyargcount"])])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
821 QTreeWidgetItem(self.codeInfoWidget, [
7712
d8eedc2e5a0a Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7711
diff changeset
822 self.tr("Keyword-only Arguments"),
7710
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
823 str(codeInfo["kwonlyargcount"])])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
824 QTreeWidgetItem(self.codeInfoWidget, [
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
825 self.tr("Number of Locals"), str(codeInfo["nlocals"])])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
826 QTreeWidgetItem(self.codeInfoWidget, [
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
827 self.tr("Stack Size"), str(codeInfo["stacksize"])])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
828 QTreeWidgetItem(self.codeInfoWidget, [
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
829 self.tr("Flags"), codeInfo["flags"]])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
830 if codeInfo["consts"]:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
831 createCodeInfoItems(self.tr("Constants"),
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
832 codeInfo["consts"])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
833 if codeInfo["names"]:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
834 createCodeInfoItems(self.tr("Names"),
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
835 codeInfo["names"])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
836 if codeInfo["varnames"]:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
837 createCodeInfoItems(self.tr("Variable Names"),
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
838 codeInfo["varnames"])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
839 if codeInfo["freevars"]:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
840 createCodeInfoItems(self.tr("Free Variables"),
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
841 codeInfo["freevars"])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
842 if codeInfo["cellvars"]:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
843 createCodeInfoItems(self.tr("Cell Variables"),
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
844 codeInfo["cellvars"])
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
845
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
846 QTimer.singleShot(0, self.__resizeCodeInfoColumns)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
847
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
848 def __resizeCodeInfoColumns(self):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
849 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
850 Private method to resize the columns of the code info widget to
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
851 suitable values.
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
852 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
853 for col in range(self.codeInfoWidget.columnCount()):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
854 self.codeInfoWidget.resizeColumnToContents(col)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
855
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
856 def __expandAllCodeInfo(self):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
857 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
858 Private slot to expand all items of the code info widget.
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
859 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
860 block = self.codeInfoWidget.blockSignals(True)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
861 self.codeInfoWidget.expandAll()
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
862 self.codeInfoWidget.blockSignals(block)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
863 self.__resizeCodeInfoColumns()
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
864
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
865 def __collapseAllCodeInfo(self):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
866 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
867 Private slot to collapse all items of the code info widget.
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
868 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
869 block = self.codeInfoWidget.blockSignals(True)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
870 self.codeInfoWidget.collapseAll()
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
871 self.codeInfoWidget.blockSignals(block)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
872 self.__resizeCodeInfoColumns()
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
873
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
874 def __codeInfoContextMenuRequested(self, coord):
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
875 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
876 Private slot to show the context menu of the code info widget.
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
877
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
878 @param coord position of the mouse pointer
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
879 @type QPoint
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
880 """
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
881 if self.disWidget.topLevelItemCount() > 0:
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
882 # don't show context menu on empty list
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
883 coord = self.codeInfoWidget.mapToGlobal(coord)
9aad21c7765d PythonDisViewer: started implementing a code info widget to show data about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
884 self.__codeInfoMenu.popup(coord)
7711
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
885
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
886 def __configure(self):
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
887 """
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
888 Private method to open the configuration dialog.
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
889 """
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
890 e5App().getObject("UserInterface").showPreferences(
5e6792b85a8a Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7710
diff changeset
891 "pythonPage")

eric ide

mercurial