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 / xxtwit_app.py < prev    next >
Encoding:
Python Source  |  1996-10-04  |  2.7 KB  |  125 lines  |  [TEXT/Pyth]

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