blob: 6054939b52920f26583649c0bec2e315f8a020e5 [file] [log] [blame]
Jack Jansen4892ab71996-09-24 15:35:50 +00001"""twit - The Window-Independent Tracer.
2
3Interface:
4twit.main() Enter debugger in inactive interactive state
5twit.run(stmt, globals, locals) Enter debugger and start running stmt
6twit.post_mortem(traceback) Enter debugger in post-mortem mode on traceback
7twit.pm() Enter debugger in pm-mode on sys.last_traceback
8
9main program: nothing but a bit of glue to put it all together.
10
11Jack Jansen, CWI, August 1996."""
12
13import os
14if os.name == 'mac':
15 import MacOS
16 MacOS.splash(515) # Try to show the splash screen
17 import mactwit_mod; twit_mod = mactwit_mod
18 import mactwit_stack; twit_stack = mactwit_stack
19 import mactwit_app; twit_app = mactwit_app
20 import mactwit_browser; twit_browser = mactwit_browser
21 import mactwit_edit; twit_edit = mactwit_edit
22else:
23 try:
24 import _tkinter
25 have_tk = 1
26 except ImportError:
27 have_tk = 0
28 if have_tk:
29 import tktwit_mod; twit_mod = tktwit_mod
30 import tktwit_stack; twit_stack = tktwit_stack
31 import tktwit_app; twit_app = tktwit_app
32 else:
33 print 'Please implementent twit_mod, twit_stack and twit_app and try again:-)'
34 sys.exit(1)
35
36import TwitCore
37import sys
38
39class Twit(twit_app.Application, TwitCore.Application):
40
41 def new_module_browser(self, *args):
42 return apply(TWIT_ModuleBrowser, args)
43
44 def new_stack_browser(self, *args):
45 return apply(TWIT_StackBrowser, args)
46
47 def new_var_browser(self, *args):
48 return apply(TWIT_VarBrowser, args)
49
50 def edit(self, *args):
51 return apply(twit_edit.edit, args)
52
53class TWIT_ModuleBrowser(twit_mod.ModuleBrowser, TwitCore.ModuleBrowser):
54 pass
55
56class TWIT_StackBrowser(twit_stack.StackBrowser, TwitCore.StackBrowser):
57 pass
58
59def TWIT_VarBrowser(parent, var):
60 return twit_browser.VarBrowser(parent).open(var)
61
62def Initialize():
63 # Gross...
64 TwitCore.AskString = twit_app.AskString
65 TwitCore.SetWatch = twit_app.SetWatch
66 TwitCore.SetCursor = twit_app.SetCursor
67
68def main():
69 twit_app.Initialize()
70 TwitCore.Initialize()
71 Initialize()
72 if os.name == 'mac':
73 MacOS.splash()
74 Twit(None, None)
75
76def run(statement, globals=None, locals=None):
77 twit_app.Initialize()
78 TwitCore.Initialize()
79 Initialize()
80 Twit((statement, globals, locals), None)
81
82def post_mortem(t):
83 twit_app.Initialize()
84 TwitCore.Initialize()
85 Initialize()
86 Twit(None, t)
87
88def pm():
89 post_mortem(sys.last_traceback)
90
91if __name__ == '__main__':
92 main()
93
94