eric6/Documentation/Source/eric6.UI.PythonDisViewer.html

changeset 7705
90a9aefd4253
child 7707
6abcf4275d0e
equal deleted inserted replaced
7704:9251c4dc4f7a 7705:90a9aefd4253
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric6.UI.PythonDisViewer</title>
4 <meta charset="UTF-8">
5 <style>
6 body {
7 background: #EDECE6;
8 margin: 0em 1em 10em 1em;
9 color: black;
10 }
11
12 h1 { color: white; background: #85774A; }
13 h2 { color: white; background: #85774A; }
14 h3 { color: white; background: #9D936E; }
15 h4 { color: white; background: #9D936E; }
16
17 a { color: #BA6D36; }
18
19 </style>
20 </head>
21 <body>
22 <a NAME="top" ID="top"></a>
23 <h1>eric6.UI.PythonDisViewer</h1>
24
25 <p>
26 Module implementing a widget to visualize the Python Disassembly for some
27 Python sources.
28 </p>
29 <h3>Global Attributes</h3>
30
31 <table>
32 <tr><td>None</td></tr>
33 </table>
34 <h3>Classes</h3>
35
36 <table>
37
38 <tr>
39 <td><a href="#PythonDisViewer">PythonDisViewer</a></td>
40 <td>Class implementing a widget to visualize the Python Disassembly for some Python sources.</td>
41 </tr>
42 </table>
43 <h3>Functions</h3>
44
45 <table>
46 <tr><td>None</td></tr>
47 </table>
48 <hr />
49 <hr />
50 <a NAME="PythonDisViewer" ID="PythonDisViewer"></a>
51 <h2>PythonDisViewer</h2>
52
53 <p>
54 Class implementing a widget to visualize the Python Disassembly for some
55 Python sources.
56 </p>
57 <h3>Derived from</h3>
58 QWidget
59 <h3>Class Attributes</h3>
60
61 <table>
62 <tr><td>EndLineRole</td></tr><tr><td>StartLineRole</td></tr>
63 </table>
64 <h3>Class Methods</h3>
65
66 <table>
67 <tr><td>None</td></tr>
68 </table>
69 <h3>Methods</h3>
70
71 <table>
72
73 <tr>
74 <td><a href="#PythonDisViewer.__init__">PythonDisViewer</a></td>
75 <td>Constructor</td>
76 </tr>
77 <tr>
78 <td><a href="#PythonDisViewer.__clearSelection">__clearSelection</a></td>
79 <td>Private method to clear all selected items.</td>
80 </tr>
81 <tr>
82 <td><a href="#PythonDisViewer.__collapseAll">__collapseAll</a></td>
83 <td>Private slot to collapse all items.</td>
84 </tr>
85 <tr>
86 <td><a href="#PythonDisViewer.__contextMenuRequested">__contextMenuRequested</a></td>
87 <td>Private slot to show the context menu.</td>
88 </tr>
89 <tr>
90 <td><a href="#PythonDisViewer.__createErrorItem">__createErrorItem</a></td>
91 <td>Private method to create a top level error item.</td>
92 </tr>
93 <tr>
94 <td><a href="#PythonDisViewer.__createInstructionItem">__createInstructionItem</a></td>
95 <td>Private method to create an item for the given instruction.</td>
96 </tr>
97 <tr>
98 <td><a href="#PythonDisViewer.__createTitleItem">__createTitleItem</a></td>
99 <td>Private method to create a title item.</td>
100 </tr>
101 <tr>
102 <td><a href="#PythonDisViewer.__disItemClicked">__disItemClicked</a></td>
103 <td>Private slot handling a user click on a Disassembly node item.</td>
104 </tr>
105 <tr>
106 <td><a href="#PythonDisViewer.__disViewerStateChanged">__disViewerStateChanged</a></td>
107 <td>Private slot to toggle the display of the Disassembly viewer.</td>
108 </tr>
109 <tr>
110 <td><a href="#PythonDisViewer.__disassembleObject">__disassembleObject</a></td>
111 <td>Private method to disassemble the given code object recursively.</td>
112 </tr>
113 <tr>
114 <td><a href="#PythonDisViewer.__editorChanged">__editorChanged</a></td>
115 <td>Private slot to handle a change of the current editor.</td>
116 </tr>
117 <tr>
118 <td><a href="#PythonDisViewer.__editorLineChanged">__editorLineChanged</a></td>
119 <td>Private slot to handle a mouse button double click in the editor.</td>
120 </tr>
121 <tr>
122 <td><a href="#PythonDisViewer.__editorSaved">__editorSaved</a></td>
123 <td>Private slot to reload the Disassembly after the connected editor was saved.</td>
124 </tr>
125 <tr>
126 <td><a href="#PythonDisViewer.__expandAll">__expandAll</a></td>
127 <td>Private slot to expand all items.</td>
128 </tr>
129 <tr>
130 <td><a href="#PythonDisViewer.__grabFocus">__grabFocus</a></td>
131 <td>Private method to grab the input focus.</td>
132 </tr>
133 <tr>
134 <td><a href="#PythonDisViewer.__lastEditorClosed">__lastEditorClosed</a></td>
135 <td>Private slot to handle the last editor closed signal of the view manager.</td>
136 </tr>
137 <tr>
138 <td><a href="#PythonDisViewer.__loadDIS">__loadDIS</a></td>
139 <td>Private method to generate the Disassembly from the source of the current editor and visualize it.</td>
140 </tr>
141 <tr>
142 <td><a href="#PythonDisViewer.__resizeColumns">__resizeColumns</a></td>
143 <td>Private method to resize the columns to suitable values.</td>
144 </tr>
145 <tr>
146 <td><a href="#PythonDisViewer.__selectChildren">__selectChildren</a></td>
147 <td>Private method to select children of the given item covering the given line number.</td>
148 </tr>
149 <tr>
150 <td><a href="#PythonDisViewer.__selectItemForEditorLine">__selectItemForEditorLine</a></td>
151 <td>Private slot to select the items corresponding with the cursor line of the current editor.</td>
152 </tr>
153 <tr>
154 <td><a href="#PythonDisViewer.__tryCompile">__tryCompile</a></td>
155 <td>Private method to attempt to compile the given source, first as an expression and then as a statement if the first approach fails.</td>
156 </tr>
157 <tr>
158 <td><a href="#PythonDisViewer.__updateItemEndLine">__updateItemEndLine</a></td>
159 <td>Private method to update an items end line based on its children.</td>
160 </tr>
161 <tr>
162 <td><a href="#PythonDisViewer.hide">hide</a></td>
163 <td>Public slot to hide the DIS viewer.</td>
164 </tr>
165 <tr>
166 <td><a href="#PythonDisViewer.preferencesChanged">preferencesChanged</a></td>
167 <td>Public slot handling changes of the Disassembly viewer settings.</td>
168 </tr>
169 <tr>
170 <td><a href="#PythonDisViewer.resizeEvent">resizeEvent</a></td>
171 <td>Protected method to handle resize events.</td>
172 </tr>
173 <tr>
174 <td><a href="#PythonDisViewer.show">show</a></td>
175 <td>Public slot to show the DIS viewer.</td>
176 </tr>
177 <tr>
178 <td><a href="#PythonDisViewer.shutdown">shutdown</a></td>
179 <td>Public method to perform shutdown actions.</td>
180 </tr>
181 </table>
182 <h3>Static Methods</h3>
183
184 <table>
185 <tr><td>None</td></tr>
186 </table>
187
188 <a NAME="PythonDisViewer.__init__" ID="PythonDisViewer.__init__"></a>
189 <h4>PythonDisViewer (Constructor)</h4>
190 <b>PythonDisViewer</b>(<i>viewmanager, parent=None</i>)
191
192 <p>
193 Constructor
194 </p>
195 <dl>
196
197 <dt><i>viewmanager</i> (ViewManager)</dt>
198 <dd>
199 reference to the viewmanager object
200 </dd>
201 <dt><i>parent</i> (QWidget)</dt>
202 <dd>
203 reference to the parent widget
204 </dd>
205 </dl>
206 <a NAME="PythonDisViewer.__clearSelection" ID="PythonDisViewer.__clearSelection"></a>
207 <h4>PythonDisViewer.__clearSelection</h4>
208 <b>__clearSelection</b>(<i></i>)
209
210 <p>
211 Private method to clear all selected items.
212 </p>
213 <a NAME="PythonDisViewer.__collapseAll" ID="PythonDisViewer.__collapseAll"></a>
214 <h4>PythonDisViewer.__collapseAll</h4>
215 <b>__collapseAll</b>(<i></i>)
216
217 <p>
218 Private slot to collapse all items.
219 </p>
220 <a NAME="PythonDisViewer.__contextMenuRequested" ID="PythonDisViewer.__contextMenuRequested"></a>
221 <h4>PythonDisViewer.__contextMenuRequested</h4>
222 <b>__contextMenuRequested</b>(<i>coord</i>)
223
224 <p>
225 Private slot to show the context menu.
226 </p>
227 <dl>
228
229 <dt><i>coord</i> (QPoint)</dt>
230 <dd>
231 position of the mouse pointer
232 </dd>
233 </dl>
234 <a NAME="PythonDisViewer.__createErrorItem" ID="PythonDisViewer.__createErrorItem"></a>
235 <h4>PythonDisViewer.__createErrorItem</h4>
236 <b>__createErrorItem</b>(<i>error</i>)
237
238 <p>
239 Private method to create a top level error item.
240 </p>
241 <dl>
242
243 <dt><i>error</i> (str)</dt>
244 <dd>
245 error message
246 </dd>
247 </dl>
248 <dl>
249 <dt>Returns:</dt>
250 <dd>
251 generated item
252 </dd>
253 </dl>
254 <dl>
255 <dt>Return Type:</dt>
256 <dd>
257 QTreeWidgetItem
258 </dd>
259 </dl>
260 <a NAME="PythonDisViewer.__createInstructionItem" ID="PythonDisViewer.__createInstructionItem"></a>
261 <h4>PythonDisViewer.__createInstructionItem</h4>
262 <b>__createInstructionItem</b>(<i>instr, parent, lasti=-1</i>)
263
264 <p>
265 Private method to create an item for the given instruction.
266 </p>
267 <dl>
268
269 <dt><i>instr</i> (dis.Instruction)</dt>
270 <dd>
271 instruction the item should be based on
272 </dd>
273 <dt><i>parent</i> (QTreeWidgetItem)</dt>
274 <dd>
275 reference to the parent item
276 </dd>
277 <dt><i>lasti</i> (int)</dt>
278 <dd>
279 index of the instruction of a traceback
280 </dd>
281 </dl>
282 <dl>
283 <dt>Returns:</dt>
284 <dd>
285 generated item
286 </dd>
287 </dl>
288 <dl>
289 <dt>Return Type:</dt>
290 <dd>
291 QTreeWidgetItem
292 </dd>
293 </dl>
294 <a NAME="PythonDisViewer.__createTitleItem" ID="PythonDisViewer.__createTitleItem"></a>
295 <h4>PythonDisViewer.__createTitleItem</h4>
296 <b>__createTitleItem</b>(<i>title, line, parentItem</i>)
297
298 <p>
299 Private method to create a title item.
300 </p>
301 <dl>
302
303 <dt><i>title</i> (str)</dt>
304 <dd>
305 titel string for the item
306 </dd>
307 <dt><i>line</i> (int)</dt>
308 <dd>
309 start line of the titled disassembly
310 </dd>
311 <dt><i>parentItem</i> (QTreeWidget or QTreeWidgetItem)</dt>
312 <dd>
313 reference to the parent item
314 </dd>
315 </dl>
316 <dl>
317 <dt>Returns:</dt>
318 <dd>
319 generated item
320 </dd>
321 </dl>
322 <dl>
323 <dt>Return Type:</dt>
324 <dd>
325 QTreeWidgetItem
326 </dd>
327 </dl>
328 <a NAME="PythonDisViewer.__disItemClicked" ID="PythonDisViewer.__disItemClicked"></a>
329 <h4>PythonDisViewer.__disItemClicked</h4>
330 <b>__disItemClicked</b>(<i>itm, column</i>)
331
332 <p>
333 Private slot handling a user click on a Disassembly node item.
334 </p>
335 <dl>
336
337 <dt><i>itm</i> (QTreeWidgetItem)</dt>
338 <dd>
339 reference to the clicked item
340 </dd>
341 <dt><i>column</i> (int)</dt>
342 <dd>
343 column number of the click
344 </dd>
345 </dl>
346 <a NAME="PythonDisViewer.__disViewerStateChanged" ID="PythonDisViewer.__disViewerStateChanged"></a>
347 <h4>PythonDisViewer.__disViewerStateChanged</h4>
348 <b>__disViewerStateChanged</b>(<i>on</i>)
349
350 <p>
351 Private slot to toggle the display of the Disassembly viewer.
352 </p>
353 <dl>
354
355 <dt><i>on</i> (bool)</dt>
356 <dd>
357 flag indicating to show the Disassembly
358 </dd>
359 </dl>
360 <a NAME="PythonDisViewer.__disassembleObject" ID="PythonDisViewer.__disassembleObject"></a>
361 <h4>PythonDisViewer.__disassembleObject</h4>
362 <b>__disassembleObject</b>(<i>co, parentItem, parentName="", lasti=-1</i>)
363
364 <p>
365 Private method to disassemble the given code object recursively.
366 </p>
367 <dl>
368
369 <dt><i>co</i> (code object)</dt>
370 <dd>
371 code object to be disassembled
372 </dd>
373 <dt><i>parentItem</i> (QTreeWidget or QTreeWidgetItem)</dt>
374 <dd>
375 reference to the parent item
376 </dd>
377 <dt><i>parentName</i> (str)</dt>
378 <dd>
379 name of the parent code object
380 </dd>
381 <dt><i>lasti</i> (int)</dt>
382 <dd>
383 index of the instruction of a traceback
384 </dd>
385 </dl>
386 <a NAME="PythonDisViewer.__editorChanged" ID="PythonDisViewer.__editorChanged"></a>
387 <h4>PythonDisViewer.__editorChanged</h4>
388 <b>__editorChanged</b>(<i>editor</i>)
389
390 <p>
391 Private slot to handle a change of the current editor.
392 </p>
393 <dl>
394
395 <dt><i>editor</i> (Editor)</dt>
396 <dd>
397 reference to the current editor
398 </dd>
399 </dl>
400 <a NAME="PythonDisViewer.__editorLineChanged" ID="PythonDisViewer.__editorLineChanged"></a>
401 <h4>PythonDisViewer.__editorLineChanged</h4>
402 <b>__editorLineChanged</b>(<i>editor, lineno</i>)
403
404 <p>
405 Private slot to handle a mouse button double click in the editor.
406 </p>
407 <dl>
408
409 <dt><i>editor</i> (Editor)</dt>
410 <dd>
411 reference to the editor, that emitted the signal
412 </dd>
413 <dt><i>lineno</i> (int)</dt>
414 <dd>
415 line number of the editor's cursor (zero based)
416 </dd>
417 </dl>
418 <a NAME="PythonDisViewer.__editorSaved" ID="PythonDisViewer.__editorSaved"></a>
419 <h4>PythonDisViewer.__editorSaved</h4>
420 <b>__editorSaved</b>(<i>editor</i>)
421
422 <p>
423 Private slot to reload the Disassembly after the connected editor was
424 saved.
425 </p>
426 <dl>
427
428 <dt><i>editor</i> (Editor)</dt>
429 <dd>
430 reference to the editor that performed a save action
431 </dd>
432 </dl>
433 <a NAME="PythonDisViewer.__expandAll" ID="PythonDisViewer.__expandAll"></a>
434 <h4>PythonDisViewer.__expandAll</h4>
435 <b>__expandAll</b>(<i></i>)
436
437 <p>
438 Private slot to expand all items.
439 </p>
440 <a NAME="PythonDisViewer.__grabFocus" ID="PythonDisViewer.__grabFocus"></a>
441 <h4>PythonDisViewer.__grabFocus</h4>
442 <b>__grabFocus</b>(<i></i>)
443
444 <p>
445 Private method to grab the input focus.
446 </p>
447 <a NAME="PythonDisViewer.__lastEditorClosed" ID="PythonDisViewer.__lastEditorClosed"></a>
448 <h4>PythonDisViewer.__lastEditorClosed</h4>
449 <b>__lastEditorClosed</b>(<i></i>)
450
451 <p>
452 Private slot to handle the last editor closed signal of the view
453 manager.
454 </p>
455 <a NAME="PythonDisViewer.__loadDIS" ID="PythonDisViewer.__loadDIS"></a>
456 <h4>PythonDisViewer.__loadDIS</h4>
457 <b>__loadDIS</b>(<i></i>)
458
459 <p>
460 Private method to generate the Disassembly from the source of the
461 current editor and visualize it.
462 </p>
463 <a NAME="PythonDisViewer.__resizeColumns" ID="PythonDisViewer.__resizeColumns"></a>
464 <h4>PythonDisViewer.__resizeColumns</h4>
465 <b>__resizeColumns</b>(<i></i>)
466
467 <p>
468 Private method to resize the columns to suitable values.
469 </p>
470 <a NAME="PythonDisViewer.__selectChildren" ID="PythonDisViewer.__selectChildren"></a>
471 <h4>PythonDisViewer.__selectChildren</h4>
472 <b>__selectChildren</b>(<i>itm, lineno</i>)
473
474 <p>
475 Private method to select children of the given item covering the given
476 line number.
477 </p>
478 <dl>
479
480 <dt><i>itm</i> (QTreeWidgetItem)</dt>
481 <dd>
482 reference to the item
483 </dd>
484 <dt><i>lineno</i> (int)</dt>
485 <dd>
486 line number to base the selection on
487 </dd>
488 </dl>
489 <a NAME="PythonDisViewer.__selectItemForEditorLine" ID="PythonDisViewer.__selectItemForEditorLine"></a>
490 <h4>PythonDisViewer.__selectItemForEditorLine</h4>
491 <b>__selectItemForEditorLine</b>(<i></i>)
492
493 <p>
494 Private slot to select the items corresponding with the cursor line
495 of the current editor.
496 </p>
497 <a NAME="PythonDisViewer.__tryCompile" ID="PythonDisViewer.__tryCompile"></a>
498 <h4>PythonDisViewer.__tryCompile</h4>
499 <b>__tryCompile</b>(<i>source, name</i>)
500
501 <p>
502 Private method to attempt to compile the given source, first as an
503 expression and then as a statement if the first approach fails.
504 </p>
505 <dl>
506
507 <dt><i>source</i> (str)</dt>
508 <dd>
509 source code string to be compiled
510 </dd>
511 <dt><i>name</i> (str)</dt>
512 <dd>
513 name of the file containing the source
514 </dd>
515 </dl>
516 <dl>
517 <dt>Returns:</dt>
518 <dd>
519 compiled code
520 </dd>
521 </dl>
522 <dl>
523 <dt>Return Type:</dt>
524 <dd>
525 code object
526 </dd>
527 </dl>
528 <a NAME="PythonDisViewer.__updateItemEndLine" ID="PythonDisViewer.__updateItemEndLine"></a>
529 <h4>PythonDisViewer.__updateItemEndLine</h4>
530 <b>__updateItemEndLine</b>(<i>itm</i>)
531
532 <p>
533 Private method to update an items end line based on its children.
534 </p>
535 <dl>
536
537 <dt><i>itm</i> (QTreeWidgetItem)</dt>
538 <dd>
539 reference to the item to be updated
540 </dd>
541 </dl>
542 <a NAME="PythonDisViewer.hide" ID="PythonDisViewer.hide"></a>
543 <h4>PythonDisViewer.hide</h4>
544 <b>hide</b>(<i></i>)
545
546 <p>
547 Public slot to hide the DIS viewer.
548 </p>
549 <a NAME="PythonDisViewer.preferencesChanged" ID="PythonDisViewer.preferencesChanged"></a>
550 <h4>PythonDisViewer.preferencesChanged</h4>
551 <b>preferencesChanged</b>(<i></i>)
552
553 <p>
554 Public slot handling changes of the Disassembly viewer settings.
555 </p>
556 <a NAME="PythonDisViewer.resizeEvent" ID="PythonDisViewer.resizeEvent"></a>
557 <h4>PythonDisViewer.resizeEvent</h4>
558 <b>resizeEvent</b>(<i>evt</i>)
559
560 <p>
561 Protected method to handle resize events.
562 </p>
563 <dl>
564
565 <dt><i>evt</i> (QResizeEvent)</dt>
566 <dd>
567 resize event
568 </dd>
569 </dl>
570 <a NAME="PythonDisViewer.show" ID="PythonDisViewer.show"></a>
571 <h4>PythonDisViewer.show</h4>
572 <b>show</b>(<i></i>)
573
574 <p>
575 Public slot to show the DIS viewer.
576 </p>
577 <a NAME="PythonDisViewer.shutdown" ID="PythonDisViewer.shutdown"></a>
578 <h4>PythonDisViewer.shutdown</h4>
579 <b>shutdown</b>(<i></i>)
580
581 <p>
582 Public method to perform shutdown actions.
583 </p>
584 <div align="right"><a href="#top">Up</a></div>
585 <hr />
586 </body></html>

eric ide

mercurial