f fJ@sddlZddlZddlZddlZddlZddlmZmZm Z ddl m Z m Z ddl mZdddddZGdddeZGd d d eZGd d d e Zd dZedkr ddlmZeendS)N)TreeNodeTreeItemScrolledCanvas)ObjectTreeItemmake_objecttreeitem)PyShellFileListcCs|dkrtj|}nt|dddd}|jjddddt||}t|jd|}|jdS) NZbgZwhiteZhighlightthicknessrexpandZfillZboth) tkZToplevelrframeZpack StackTreeItemrZcanvasr)rootflisttbtopZscitemZnoder8/opt/alt/python34/lib64/python3.4/idlelib/StackViewer.py StackBrowser s rc@sReZdZddddZddZddZdd Zd d ZdS) r NcCs.||_|j||_|j|_dS)N)r get_stackstack get_exceptiontext)selfrrrrr__init__s zStackTreeItem.__init__cCsx|dkrtj}ng}|r?|jdkr?|j}nx2|dk rs|j|j|jf|j}qBW|S)N)syslast_tracebacktb_frametb_nextappend tb_lineno)rrrrrrrs    zStackTreeItem.get_stackcCs`tj}tj}t|dr-|j}nt|}|dk r\|dt|}n|S)N__name__z: )r last_type last_valuehasattrr!str)rtypevaluesrrrr&s     zStackTreeItem.get_exceptioncCs|jS)N)r)rrrrGetText0szStackTreeItem.GetTextcCs=g}x0|jD]%}t||j}|j|qW|S)N)r FrameTreeItemrr)rsublistinforrrr GetSubList3s zStackTreeItem.GetSubList)r! __module__ __qualname__rrrr)r-rrrrr s  r c@s@eZdZddZddZddZddZd S) r*cCs||_||_dS)N)r,r)rr,rrrrr<s zFrameTreeItem.__init__c Cs|j\}}y|jd}Wnd}YnX|j}|j}|j}tj||}|j}|dkrd|||f}nd||||f}|S)Nr!?z%s, line %d: %sz%s.%s(...), line %d: %s)r0r1N)r, f_globalsf_code co_filenameco_name linecachegetlinestrip) rr linenomodnamecodefilenameZfuncnameZ sourcelinerrrrr)@s        zFrameTreeItem.GetTextcCsx|j\}}g}|j|jk rOtd|j|j}|j|ntd|j|j}|j||S)Nzz )r,r2f_localsVariablesTreeItemrr)rr r9r+rrrrr-Rs zFrameTreeItem.GetSubListcCsS|jrO|j\}}|jj}tjj|rO|jj||qOndS)N)rr,r3r4ospathisfileZ gotofileline)rr r9r<rrr OnDoubleClick\s   zFrameTreeItem.OnDoubleClickN)r!r.r/rr)r-rBrrrrr*:s    r*c@sLeZdZddZddZddZddZd d Zd S) r>cCs|jS)N)Z labeltext)rrrrr)eszVariablesTreeItem.GetTextcCsdS)Nr)rrrr GetLabelTexthszVariablesTreeItem.GetLabelTextcCst|jdkS)Nr)lenobject)rrrr IsExpandablekszVariablesTreeItem.IsExpandablec Csg}xx|jjD]g}y|j|}Wntk rDwYnX||jdd}t|d||}|j|qW|S)NcSs|||.setfunctionz =)rEkeysKeyErrorrr)rr+rGr'rHrrrrr-ns zVariablesTreeItem.GetSubListcCst|jjS)N)listrErI)rrrrrI{szVariablesTreeItem.keysN)r!r.r/r)rCrFr-rIrrrrr>cs     r>c Cstj}|jdttttjd|j\}}}}|jd||dft |}yt Wn't k rt j \}}} YnX|t _|t _| t _t|d|d|d| t `t `t `dS)NzTest StackViewerz[x+]z+%d+%drrr)r ZTktitlerKmapintresplitZgeometryrZintentional_name_error NameErrorrexc_infor"r#rr) parentr widthZheightxyrexc_type exc_valueZexc_tbrrr _stack_viewer~s   3     rZ__main__)run)r?rr6rPZtkinterr Zidlelib.TreeWidgetrrrZidlelib.ObjectBrowserrrZidlelib.PyShellrrr r*r>rZr!Zidlelib.idle_test.htestr\rrrrs      &)