diff options
author | Guido van Rossum <guido@python.org> | 1998-10-14 03:43:05 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-10-14 03:43:05 (GMT) |
commit | 35e55da7dce202b985b1735b9ae9b0080a993ba4 (patch) | |
tree | fef9652ddaf35547eae088d23b6dbb3ddccd32c8 | |
parent | fc6aba5008caede94ad65a9cf387b3ba971d5379 (diff) | |
download | cpython-35e55da7dce202b985b1735b9ae9b0080a993ba4.zip cpython-35e55da7dce202b985b1735b9ae9b0080a993ba4.tar.gz cpython-35e55da7dce202b985b1735b9ae9b0080a993ba4.tar.bz2 |
Polish the Debugger GUI a bit.
Closing it now also does the right thing.
-rw-r--r-- | Tools/idle/Debugger.py | 48 | ||||
-rw-r--r-- | Tools/idle/PyShell.py | 24 |
2 files changed, 52 insertions, 20 deletions
diff --git a/Tools/idle/Debugger.py b/Tools/idle/Debugger.py index 3a16a12..a292b4c 100644 --- a/Tools/idle/Debugger.py +++ b/Tools/idle/Debugger.py @@ -6,13 +6,26 @@ from Tkinter import * class Debugger(bdb.Bdb): + interacting = 0 + def __init__(self, pyshell): bdb.Bdb.__init__(self) self.pyshell = pyshell self.make_gui() def close(self): + if self.interacting: + self.top.bell() + return + self.pyshell.close_debugger() self.top.destroy() + + def run(self, *args): + try: + self.interacting = 1 + return apply(bdb.Bdb.run, (self,) + args) + finally: + self.interacting = 0 def user_line(self, frame): self.interaction(frame) @@ -29,8 +42,9 @@ class Debugger(bdb.Bdb): self.flist = pyshell.flist self.root = root = pyshell.root self.top = top = Toplevel(root) + top.wm_protocol("WM_DELETE_WINDOW", self.close) self.bframe = bframe = Frame(top) - self.bframe.pack() + self.bframe.pack(anchor="w") self.buttons = bl = [] self.bcont = b = Button(bframe, text="Go", command=self.cont) bl.append(b) @@ -43,25 +57,34 @@ class Debugger(bdb.Bdb): for b in bl: b.configure(state="disabled") b.pack(side="left") - self.status = Label(top) - self.status.pack() + self.status = Label(top, anchor="w") + self.status.pack(anchor="w") + self.error = Label(top, anchor="w") + self.error.pack(anchor="w") def interaction(self, frame, info=None): + self.top.pack_propagate(0) self.frame = frame code = frame.f_code file = code.co_filename + base = os.path.basename(file) lineno = frame.f_lineno - message = "file=%s, name=%s, line=%s" % (file, code.co_name, lineno) + message = "%s:%s: %s()" % (base, lineno, code.co_name) + self.status.configure(text=message) if info: type, value, tb = info - m1 = "%s" % str(type) -## if value is not None: -## try: -## m1 = "%s: %s" % (m1, str(value)) -## except: -## pass - message = "%s\n%s" % (message, m1) - self.status.configure(text=message) + try: + m1 = type.__name__ + except AttributeError: + m1 = "%s" % str(type) + if value is not None: + try: + m1 = "%s: %s" % (m1, str(value)) + except: + pass + else: + m1 = "" + self.error.configure(text=m1) if file[:1] + file[-1:] != "<>" and os.path.exists(file): edit = self.flist.open(file) if edit: @@ -73,6 +96,7 @@ class Debugger(bdb.Bdb): for b in self.buttons: b.configure(state="disabled") self.status.configure(text="") + self.error.configure(text="") self.frame = None def cont(self): diff --git a/Tools/idle/PyShell.py b/Tools/idle/PyShell.py index 4cabc3e..a794def 100644 --- a/Tools/idle/PyShell.py +++ b/Tools/idle/PyShell.py @@ -252,19 +252,27 @@ class PyShell(PyShellEditorWindow): return "break" db = self.interp.getdebugger() if db: + self.close_debugger() + else: + self.open_debugger() + + def close_debugger(self): + db = self.interp.getdebugger() + if db: + self.interp.setdebugger(None) db.close() self.resetoutput() self.console.write("[DEBUG OFF]\n") sys.ps1 = ">>> " self.showprompt() - self.interp.setdebugger(None) - else: - import Debugger - self.interp.setdebugger(Debugger.Debugger(self)) - sys.ps1 = "[DEBUG ON]>>> " - self.showprompt() - self.top.tkraise() - self.text.focus_set() + + def open_debugger(self): + import Debugger + self.interp.setdebugger(Debugger.Debugger(self)) + sys.ps1 = "[DEBUG ON]>>> " + self.showprompt() + self.top.tkraise() + self.text.focus_set() def beginexecuting(self): # Helper for ModifiedInterpreter |