blob: d12bca2dec2f3741f8ae866ac4adbf62e704130a [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':
Jack Jansen5c303881996-09-25 14:08:40 +000015# Not supported in distributed 1.4b3:
16## import MacOS
17## MacOS.splash(515) # Try to show the splash screen
Jack Jansen4892ab71996-09-24 15:35:50 +000018 import mactwit_mod; twit_mod = mactwit_mod
19 import mactwit_stack; twit_stack = mactwit_stack
20 import mactwit_app; twit_app = mactwit_app
21 import mactwit_browser; twit_browser = mactwit_browser
22 import mactwit_edit; twit_edit = mactwit_edit
23else:
24 try:
25 import _tkinter
26 have_tk = 1
27 except ImportError:
28 have_tk = 0
29 if have_tk:
30 import tktwit_mod; twit_mod = tktwit_mod
31 import tktwit_stack; twit_stack = tktwit_stack
32 import tktwit_app; twit_app = tktwit_app
33 else:
34 print 'Please implementent twit_mod, twit_stack and twit_app and try again:-)'
35 sys.exit(1)
36
37import TwitCore
38import sys
39
40class Twit(twit_app.Application, TwitCore.Application):
41
42 def new_module_browser(self, *args):
43 return apply(TWIT_ModuleBrowser, args)
44
45 def new_stack_browser(self, *args):
46 return apply(TWIT_StackBrowser, args)
47
48 def new_var_browser(self, *args):
49 return apply(TWIT_VarBrowser, args)
50
51 def edit(self, *args):
52 return apply(twit_edit.edit, args)
53
54class TWIT_ModuleBrowser(twit_mod.ModuleBrowser, TwitCore.ModuleBrowser):
55 pass
56
57class TWIT_StackBrowser(twit_stack.StackBrowser, TwitCore.StackBrowser):
58 pass
59
60def TWIT_VarBrowser(parent, var):
61 return twit_browser.VarBrowser(parent).open(var)
62
63def Initialize():
64 # Gross...
65 TwitCore.AskString = twit_app.AskString
Jack Jansen5c303881996-09-25 14:08:40 +000066 TwitCore.ShowMessage = twit_app.ShowMessage
Jack Jansen4892ab71996-09-24 15:35:50 +000067 TwitCore.SetWatch = twit_app.SetWatch
68 TwitCore.SetCursor = twit_app.SetCursor
69
70def main():
71 twit_app.Initialize()
72 TwitCore.Initialize()
73 Initialize()
Jack Jansen5c303881996-09-25 14:08:40 +000074## if os.name == 'mac':
75## MacOS.splash()
Jack Jansen4892ab71996-09-24 15:35:50 +000076 Twit(None, None)
77
78def run(statement, globals=None, locals=None):
79 twit_app.Initialize()
80 TwitCore.Initialize()
81 Initialize()
82 Twit((statement, globals, locals), None)
83
84def post_mortem(t):
85 twit_app.Initialize()
86 TwitCore.Initialize()
87 Initialize()
88 Twit(None, t)
89
90def pm():
91 post_mortem(sys.last_traceback)
92
93if __name__ == '__main__':
94 main()
95
96