Refactored, with some future plans in mind.
This now uses the new gotofileline() method defined in FileList.py.
This commit is contained in:
parent
6cb7a21934
commit
e9d7f0779d
|
@ -1,24 +1,27 @@
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
import string
|
import string
|
||||||
from Tkinter import *
|
|
||||||
import linecache
|
import linecache
|
||||||
|
|
||||||
from TreeWidget import TreeNode, TreeItem, ScrolledCanvas
|
from TreeWidget import TreeNode, TreeItem, ScrolledCanvas
|
||||||
from ObjectBrowser import ObjectTreeItem, make_objecttreeitem
|
from ObjectBrowser import ObjectTreeItem, make_objecttreeitem
|
||||||
from OldStackViewer import StackViewer, NamespaceViewer
|
from OldStackViewer import StackViewer, NamespaceViewer
|
||||||
|
|
||||||
def StackBrowser(root, flist=None, stack=None):
|
def StackBrowser(root, flist=None, tb=None, top=None):
|
||||||
top = Toplevel(root)
|
if top is None:
|
||||||
|
from Tkinter import Toplevel
|
||||||
|
top = Toplevel(root)
|
||||||
sc = ScrolledCanvas(top, bg="white", highlightthickness=0)
|
sc = ScrolledCanvas(top, bg="white", highlightthickness=0)
|
||||||
sc.frame.pack(expand=1, fill="both")
|
sc.frame.pack(expand=1, fill="both")
|
||||||
item = StackTreeItem(flist)
|
item = StackTreeItem(flist, tb)
|
||||||
node = TreeNode(sc.canvas, None, item)
|
node = TreeNode(sc.canvas, None, item)
|
||||||
node.expand()
|
node.expand()
|
||||||
|
|
||||||
class StackTreeItem(TreeItem):
|
class StackTreeItem(TreeItem):
|
||||||
|
|
||||||
def __init__(self, flist=None):
|
def __init__(self, flist=None, tb=None):
|
||||||
self.flist = flist
|
self.flist = flist
|
||||||
self.stack = get_stack()
|
self.stack = get_stack(tb)
|
||||||
self.text = get_exception()
|
self.text = get_exception()
|
||||||
|
|
||||||
def GetText(self):
|
def GetText(self):
|
||||||
|
@ -71,8 +74,8 @@ class FrameTreeItem(TreeItem):
|
||||||
if self.flist:
|
if self.flist:
|
||||||
frame, lineno = self.info
|
frame, lineno = self.info
|
||||||
filename = frame.f_code.co_filename
|
filename = frame.f_code.co_filename
|
||||||
edit = self.flist.open(filename)
|
if os.path.isfile(filename):
|
||||||
edit.gotoline(lineno)
|
self.flist.gotofileline(filename, lineno)
|
||||||
|
|
||||||
class VariablesTreeItem(ObjectTreeItem):
|
class VariablesTreeItem(ObjectTreeItem):
|
||||||
|
|
||||||
|
@ -129,7 +132,16 @@ def get_exception(type=None, value=None):
|
||||||
s = s + ": " + str(value)
|
s = s + ": " + str(value)
|
||||||
return s
|
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 = Tk()
|
||||||
root.withdraw()
|
StackBrowser(None, top=root)
|
||||||
StackBrowser(root)
|
root.mainloop()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
_test()
|
||||||
|
|
Loading…
Reference in New Issue