Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8571ed8

Browse files
committed
Add a label at the top showing (very basic) help for the stack viewer.
Add a label at the bottom showing the exception info.
1 parent 3d0669d commit 8571ed8

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Tools/idle/StackViewer.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ def __init__(self, root=None, flist=None):
2121
self.root = root
2222
self.top = top
2323
top.wm_title("Stack viewer")
24+
# Create help label
25+
self.helplabel = Label(top,
26+
text="Click once to view variables; twice for source",
27+
borderwidth=2, relief="groove")
28+
self.helplabel.pack(fill="x")
2429
# Create top frame, with scrollbar and listbox
2530
self.topframe = Frame(top)
2631
self.topframe.pack(fill="both", expand=1)
@@ -38,10 +43,14 @@ def __init__(self, root=None, flist=None):
3843
self.listbox.bind("<ButtonPress-3>", self.popup_event)
3944
self.listbox.bind("<Key-Up>", self.up_event)
4045
self.listbox.bind("<Key-Down>", self.down_event)
46+
# Create status label
47+
self.statuslabel = Label(top, text="status")
48+
self.statuslabel.pack(fill="x")
4149
# Load the stack
4250
linecache.checkcache()
4351
stack = getstack()
4452
self.load_stack(stack)
53+
self.statuslabel.config(text=getexception())
4554

4655
def load_stack(self, stack):
4756
self.stack = stack
@@ -232,6 +241,18 @@ def getstack(t=None, f=None):
232241
return stack
233242

234243

244+
def getexception(type=None, value=None):
245+
if type is None:
246+
type = sys.last_type
247+
value = sys.last_value
248+
if hasattr(type, "__name__"):
249+
type = type.__name__
250+
s = str(type)
251+
if value is not None:
252+
s = s + ": " + str(value)
253+
return s
254+
255+
235256
class NamespaceViewer:
236257

237258
def __init__(self, frame, title, dict):

0 commit comments

Comments
 (0)