summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-05-12 12:30:04 (GMT)
committerGuido van Rossum <guido@python.org>2001-05-12 12:30:04 (GMT)
commite9d7f0779d44c355f406f4da58fdda4f7aee7442 (patch)
tree7a22c7de4a2f9da02aec1d77e14eb717fa7919e9 /Tools
parent6cb7a21934d2579152b9dedc8b4c87e7c8b3faaa (diff)
downloadcpython-e9d7f0779d44c355f406f4da58fdda4f7aee7442.zip
cpython-e9d7f0779d44c355f406f4da58fdda4f7aee7442.tar.gz
cpython-e9d7f0779d44c355f406f4da58fdda4f7aee7442.tar.bz2
Refactored, with some future plans in mind.
This now uses the new gotofileline() method defined in FileList.py.
Diffstat (limited to 'Tools')
-rw-r--r--Tools/idle/StackViewer.py34
1 files changed, 23 insertions, 11 deletions
diff --git a/Tools/idle/StackViewer.py b/Tools/idle/StackViewer.py
index ab09db0..d70658b 100644
--- a/Tools/idle/StackViewer.py
+++ b/Tools/idle/StackViewer.py
@@ -1,24 +1,27 @@
+import os
+import sys
import string
-from Tkinter import *
import linecache
from TreeWidget import TreeNode, TreeItem, ScrolledCanvas
from ObjectBrowser import ObjectTreeItem, make_objecttreeitem
from OldStackViewer import StackViewer, NamespaceViewer
-def StackBrowser(root, flist=None, stack=None):
- top = Toplevel(root)
+def StackBrowser(root, flist=None, tb=None, top=None):
+ if top is None:
+ from Tkinter import Toplevel
+ top = Toplevel(root)
sc = ScrolledCanvas(top, bg="white", highlightthickness=0)
sc.frame.pack(expand=1, fill="both")
- item = StackTreeItem(flist)
+ item = StackTreeItem(flist, tb)
node = TreeNode(sc.canvas, None, item)
node.expand()
class StackTreeItem(TreeItem):
- def __init__(self, flist=None):
+ def __init__(self, flist=None, tb=None):
self.flist = flist
- self.stack = get_stack()
+ self.stack = get_stack(tb)
self.text = get_exception()
def GetText(self):
@@ -71,8 +74,8 @@ class FrameTreeItem(TreeItem):
if self.flist:
frame, lineno = self.info
filename = frame.f_code.co_filename
- edit = self.flist.open(filename)
- edit.gotoline(lineno)
+ if os.path.isfile(filename):
+ self.flist.gotofileline(filename, lineno)
class VariablesTreeItem(ObjectTreeItem):
@@ -129,7 +132,16 @@ def get_exception(type=None, value=None):
s = s + ": " + str(value)
return s
-if __name__ == "__main__":
+def _test():
+ try:
+ import testcode
+ reload(testcode)
+ except:
+ sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info()
+ from Tkinter import Tk
root = Tk()
- root.withdraw()
- StackBrowser(root)
+ StackBrowser(None, top=root)
+ root.mainloop()
+
+if __name__ == "__main__":
+ _test()