home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Python 1.4 / Python 1.4 source / Mac / Tools / twit / tktwit_app.py < prev    next >
Encoding:
Python Source  |  1996-10-04  |  2.7 KB  |  122 lines  |  [TEXT/Pyth]

  1. import TwitCore
  2. import tktwit_mod
  3. import tktwit_stack
  4. #import tktwit_browser
  5. import tktwit_edit
  6.  
  7. class Twit(TwitCore.Application):
  8.     """The twit main class - Tk-dependent part"""
  9.  
  10.     def __init__(self, sessiontype, arg=None):
  11.         self.setstate(sessiontype)
  12.         self.real_quit = 0
  13.  
  14.         # Next create our dialogs
  15.         self.mi_init(sessiontype, arg)
  16.         while 1:
  17.             if self.real_quit:
  18.                 break
  19.             if self.initial_cmd:
  20.                 self.to_debugger()    # Will get to mainloop via debugger
  21.             else:
  22.                 self.one_mainloop()    # Else do it ourselves.
  23.                 
  24.     def switch_to_app(self):
  25.         """Tell windowsystem we are switching to the app"""
  26.         pass
  27.         
  28.     def switch_to_dbg(self):
  29.         """Tell windowsystem we are switching to the debugger"""
  30.         pass
  31.  
  32.         
  33.     def setstate(self, state):
  34.         """Change UI-element state based on self.state"""
  35.         pass
  36.             
  37.     def asknewsession(self):
  38.         """Ask user whether aborting current session is ok"""
  39.         if self.state == 'none':
  40.             return 1
  41.         pass # Ask whether it is ok to abort current session
  42.         return 0
  43.  
  44.     def exit_mainloop(self):
  45.         """Signal UI-mainloop to exit"""
  46.         pass # Quit windowinterface mainloop
  47.         self.real_quit = 0
  48.         
  49.     def one_mainloop(self):
  50.         """Dive into UI mainloop until exit_mainloop() is called"""
  51.         pass
  52.  
  53.     # Open various windows
  54.     def new_module_browser(self, parent):
  55.         """Open a module browser"""
  56.         return mactwit_mod.ModuleBrowser(parent)
  57.         
  58.     def new_stack_browser(self, parent):
  59.         """Open a stack browser/main window"""
  60.         return mactwit_stack.StackBrowser(parent)
  61.         
  62.     def new_var_browser(self, parent, var):
  63.         """Open a variable browser"""
  64.         return mactwit_browser.VarBrowser(parent).open(var)
  65.     
  66.     def edit(self, file, line):
  67.         """Edit a file"""
  68.         return mactwit_edit(file, line)
  69.         
  70.     # Convenience functions
  71.     def SetCursor(self):
  72.         """Set cursor to arrow"""
  73.         pass
  74.     
  75.     def SetWatch(self):
  76.         """Set cursor to watch"""
  77.         pass
  78.         
  79.     def AskString(self, *args):
  80.         """Ask the user for a string"""
  81.         pass
  82.         
  83.     def Message(self, *args):
  84.         """Show the user a message"""
  85.         pass
  86.         
  87.     # Callbacks from menus/buttons
  88.             
  89.     def do_open(self, *args):
  90.         if not self.asknewsession():
  91.             return
  92.         filename = None # Ask for file
  93.         self.runfile(filename)
  94.         
  95.     def do_run(self, *args):
  96.         if not self.asknewsession():
  97.             return
  98.         self.run()
  99.         
  100.     def do_quit(self, *args):
  101.         self.exit_mainloop()
  102.         self.real_quit = 1
  103.         self.quit_bdb()            # Tell debugger to quit.
  104.  
  105.     def do_step(self, *args):
  106.         self.run_dialog.click_step()
  107.         
  108.     def do_stepin(self, *args):
  109.         self.run_dialog.click_step_in()
  110.         
  111.     def do_stepout(self, *args):
  112.         self.run_dialog.click_step_out()
  113.         
  114.     def do_continue(self, *args):
  115.         self.run_dialog.click_continue()
  116.         
  117.     def do_kill(self, *args):
  118.         self.run_dialog.click_kill()
  119.                     
  120. def Initialize():
  121.     pass # Do window-system dependent initializations
  122.