]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/ide/activegrid/tool/DebuggerService.py
Add code to remove the selection (if any) in wxTextCtrl::WriteText for multi-line...
[wxWidgets.git] / wxPython / samples / ide / activegrid / tool / DebuggerService.py
index 79e78e04663926cdbb79b9863ae05e104557221c..485853611bfbcc7d169bbcabcefb70a81d26ba4c 100644 (file)
@@ -41,6 +41,7 @@ import pickle
 import DebuggerHarness
 import traceback
 import StringIO
+import UICommon
 if wx.Platform == '__WXMSW__':
     try:
         import win32api
@@ -72,7 +73,12 @@ class OutputReaderThread(threading.Thread):
         self._lineCount = 0
         self._accumulate = accumulate
         self._callbackOnExit = callbackOnExit
-         
+        self.setDaemon(True)
+    
+    def __del__(self):
+        # See comment on DebugCommandUI.StopExecution
+        self._keepGoing = False
+             
     def run(self):
         file = self._file
         start = time.time()
@@ -83,7 +89,7 @@ class OutputReaderThread(threading.Thread):
                 text = file.readline()
                 if text == '' or text == None:
                     self._keepGoing = False
-                elif not self._accumulate:
+                elif not self._accumulate and self._keepGoing:
                     self._callback_function(text)
                 else:
                     # Should use a buffer? StringIO?
@@ -91,11 +97,11 @@ class OutputReaderThread(threading.Thread):
                 # Seems as though the read blocks if we got an error, so, to be
                 # sure that at least some of the exception gets printed, always 
                 # send the first hundred lines back as they come in.
-                if self._lineCount < 100:    
+                if self._lineCount < 100 and self._keepGoing:    
                     self._callback_function(output)
                     self._lineCount += 1
                     output = "" 
-                elif time.time() - start > 0.25:
+                elif time.time() - start > 0.25 and self._keepGoing:
                     try:
                         self._callback_function(output) 
                     except wx._core.PyDeadObjectError:
@@ -103,8 +109,8 @@ class OutputReaderThread(threading.Thread):
                         self._keepGoing = False
                     start = time.time()
                     output = "" 
-            except TypeError:
-                pass
+            #except TypeError:
+            #    pass
             except:
                 tp, val, tb = sys.exc_info()
                 print "Exception in OutputReaderThread.run():", tp, val
@@ -118,7 +124,7 @@ class OutputReaderThread(threading.Thread):
         
     def AskToStop(self):
         self._keepGoing = False
-        
+                
 import  wx.lib.newevent
 (UpdateTextEvent, EVT_UPDATE_STDTEXT) = wx.lib.newevent.NewEvent()
 (UpdateErrorEvent, EVT_UPDATE_ERRTEXT) = wx.lib.newevent.NewEvent()
@@ -126,8 +132,7 @@ import  wx.lib.newevent
 class Executor:
     
     def GetPythonExecutablePath():
-        config = wx.ConfigBase_Get()
-        path = config.Read("ActiveGridPythonLocation")
+        path = UICommon.GetPythonExecPath()
         if path:
             return path
         wx.MessageBox(_("To proceed I need to know the location of the python.exe you would like to use.\nTo set this, go to Tools-->Options and use the 'Python' tab to enter a value.\n"), _("Python Executable Location Unknown"))
@@ -143,29 +148,33 @@ class Executor:
         path = Executor.GetPythonExecutablePath()
         self._cmd = '"' + path + '" -u \"' + fileName + '\"'
         #Better way to do this? Quotes needed for windows file paths.
+        def spaceAndQuote(text):
+            if text.startswith("\"") and text.endswith("\""):
+                return  ' ' + text
+            else:
+                return ' \"' + text + '\"'
         if(arg1 != None):
-            self._cmd += ' \"' + arg1 + '\"'
+            self._cmd += spaceAndQuote(arg1)
         if(arg2 != None):
-            self._cmd += ' \"' + arg2 + '\"'
+            self._cmd += spaceAndQuote(arg2)
         if(arg3 != None):
-            self._cmd += ' \"' + arg3 + '\"'
+            self._cmd += spaceAndQuote(arg3)
         if(arg4 != None):
-            self._cmd += ' \"' + arg4 + '\"'
+            self._cmd += spaceAndQuote(arg4)
         if(arg5 != None):
-            self._cmd += ' \"' + arg5 + '\"'
+            self._cmd += spaceAndQuote(arg5)
         if(arg6 != None):
-            self._cmd += ' \"' + arg6 + '\"'
+            self._cmd += spaceAndQuote(arg6)
         if(arg7 != None):
-            self._cmd += ' \"' + arg7 + '\"'
+            self._cmd += spaceAndQuote(arg7)
         if(arg8 != None):
-            self._cmd += ' \"' + arg8 + '\"'
+            self._cmd += spaceAndQuote(arg8)
         if(arg9 != None):
-            self._cmd += ' \"' + arg9 + '\"'
+            self._cmd += spaceAndQuote(arg9)
         
         self._stdOutReader = None
         self._stdErrReader = None
         self._process = None
-        DebuggerService.executors.append(self)
         
     def OutCall(self, text):
         evt = UpdateTextEvent(value = text)
@@ -180,8 +189,6 @@ class Executor:
             startIn = str(os.getcwd())
         startIn = os.path.abspath(startIn)
         command = self._cmd + ' ' + arguments
-        #stdinput = process.IOBuffer()
-        #self._process = process.ProcessProxy(command, mode='b', cwd=startIn, stdin=stdinput)
         self._process = process.ProcessOpen(command, mode='b', cwd=startIn, env=environment)
         # Kick off threads to read stdout and stderr and write them
         # to our text control. 
@@ -189,35 +196,46 @@ class Executor:
         self._stdOutReader.start()
         self._stdErrReader = OutputReaderThread(self._process.stderr, self._stdErrCallback, accumulate=False)
         self._stdErrReader.start()
-                
-    
+                        
     def DoStopExecution(self):
+        # See comment on DebugCommandUI.StopExecution
         if(self._process != None):
-            self._process.kill()
-            self._process.close()
-            self._process = None
-        if(self._stdOutReader != None):
             self._stdOutReader.AskToStop()
-        if(self._stdErrReader != None):
             self._stdErrReader.AskToStop()
-        DebuggerService.executors.remove(self)
+            try:
+                self._process.kill(gracePeriod=2.0)
+            except:
+                pass
+            self._process = None
         
 class RunCommandUI(wx.Panel):
+    runners = []
+    
+    def ShutdownAllRunners():
+        # See comment on DebugCommandUI.StopExecution
+        for runner in RunCommandUI.runners:
+            try:
+                runner.StopExecution(None)
+            except wx._core.PyDeadObjectError:
+                pass
+        RunCommandUI.runners = []    
+    ShutdownAllRunners = staticmethod(ShutdownAllRunners)
     
     def __init__(self, parent, id, fileName):
         wx.Panel.__init__(self, parent, id)
         self._noteBook = parent
         
+        threading._VERBOSE = _VERBOSE
+        
         self.KILL_PROCESS_ID = wx.NewId()
         self.CLOSE_TAB_ID = wx.NewId()
         
-        self.Bind(wx.EVT_END_PROCESS, self.OnProcessEnded)
         
         # GUI Initialization follows
         sizer = wx.BoxSizer(wx.HORIZONTAL)
         self._tb = tb = wx.ToolBar(self,  -1, wx.DefaultPosition, (30,1000), wx.TB_VERTICAL| wx.TB_FLAT, "Runner" )
         tb.SetToolBitmapSize((16,16))
-        sizer.Add(tb, 0, wx.EXPAND |wx.ALIGN_LEFT|wx.ALL, 1)
+        sizer.Add(tb, 0, wx.EXPAND|wx.ALIGN_LEFT|wx.ALL, 1)
 
         close_bmp = getCloseBitmap()
         tb.AddSimpleTool( self.CLOSE_TAB_ID, close_bmp, _('Close Window'))
@@ -245,12 +263,16 @@ class RunCommandUI(wx.Panel):
         self.SetSizer(sizer)
         sizer.Fit(self)
         
+        self._stopped = False
         # Executor initialization
         self._executor = Executor(fileName, self, callbackOnExit=self.ExecutorFinished)
         self.Bind(EVT_UPDATE_STDTEXT, self.AppendText)
         self.Bind(EVT_UPDATE_ERRTEXT, self.AppendErrorText)
         
+        RunCommandUI.runners.append(self)
+        
     def __del__(self):
+        # See comment on DebugCommandUI.StopExecution
         self._executor.DoStopExecution()
                  
     def Execute(self, initialArgs, startIn, environment):
@@ -267,9 +289,11 @@ class RunCommandUI(wx.Panel):
                 break
            
     def StopExecution(self):
-        self.Unbind(EVT_UPDATE_STDTEXT)
-        self.Unbind(EVT_UPDATE_ERRTEXT)
-        self._executor.DoStopExecution()
+        if not self._stopped:
+            self._stopped = True
+            self.Unbind(EVT_UPDATE_STDTEXT)
+            self.Unbind(EVT_UPDATE_ERRTEXT)
+            self._executor.DoStopExecution()
         
     def AppendText(self, event):
         self._textCtrl.SetReadOnly(False)
@@ -286,6 +310,13 @@ class RunCommandUI(wx.Panel):
         self._textCtrl.SetFontColor(wx.BLACK)   
         self._textCtrl.StyleClearAll()
         self._textCtrl.SetReadOnly(True)
+
+    def StopAndRemoveUI(self, event):
+        self.StopExecution()
+        self.StopExecution()
+        index = self._noteBook.GetSelection()
+        self._noteBook.GetPage(index).Show(False)
+        self._noteBook.RemovePage(index)
         
     #------------------------------------------------------------------------------
     # Event handling
@@ -295,13 +326,10 @@ class RunCommandUI(wx.Panel):
         id = event.GetId()
         
         if id == self.KILL_PROCESS_ID:
-            self._executor.DoStopExecution()
+            self.StopExecution()
             
         elif id == self.CLOSE_TAB_ID:
-            self._executor.DoStopExecution()
-            index = self._noteBook.GetSelection()
-            self._noteBook.GetPage(index).Show(False)
-            self._noteBook.RemovePage(index)
+            self.StopAndRemoveUI(event)
             
     def OnDoubleClick(self, event):
         # Looking for a stack trace line.
@@ -344,13 +372,11 @@ class RunCommandUI(wx.Panel):
         # FACTOR THIS INTO DocManager
         openDocs = wx.GetApp().GetDocumentManager().GetDocuments()
         for openDoc in openDocs:  
-            if(isinstance(openDoc.GetFirstView(), CodeEditor.CodeView)): 
+            if(isinstance(openDoc, CodeEditor.CodeDocument)): 
                 openDoc.GetFirstView().GetCtrl().ClearCurrentLineMarkers()    
                 
         foundView.GetCtrl().MarkerAdd(lineNum -1, CodeEditor.CodeCtrl.CURRENT_LINE_MARKER_NUM)
 
-    def OnProcessEnded(self, evt):
-        self._executor.DoStopExecution()
 
 DEFAULT_PORT = 32032
 DEFAULT_HOST = 'localhost' 
@@ -374,9 +400,13 @@ class DebugCommandUI(wx.Panel):
     DebuggerRunning = staticmethod(DebuggerRunning)
     
     def ShutdownAllDebuggers():
+        # See comment on DebugCommandUI.StopExecution
         for debugger in DebugCommandUI.debuggers:
-            debugger.StopExecution(None)
-            
+            try:
+                debugger.StopExecution(None)
+            except wx._core.PyDeadObjectError:
+                pass
+        DebugCommandUI.debuggers = []    
     ShutdownAllDebuggers = staticmethod(ShutdownAllDebuggers)
     
     def GetAvailablePort():
@@ -393,8 +423,9 @@ class DebugCommandUI(wx.Panel):
     def ReturnPortToPool(port):
         config = wx.ConfigBase_Get()
         startingPort = config.ReadInt("DebuggerStartingPort", DEFAULT_PORT)
-        if port in range(startingPort, startingPort + PORT_COUNT):
-            DebugCommandUI.debuggerPortList.append(port)
+        val = int(startingPort) + int(PORT_COUNT)
+        if int(port) >= startingPort and (int(port) <= val):
+            DebugCommandUI.debuggerPortList.append(int(port))
             
     ReturnPortToPool = staticmethod(ReturnPortToPool)
 
@@ -549,9 +580,8 @@ class DebugCommandUI(wx.Panel):
         self.framesTab.PopulateBPList()
         
     def __del__(self):
-        if self in DebugCommandUI.debuggers:
-            DebugCommandUI.debuggers.remove(self)
-        
+        # See comment on DebugCommandUI.StopExecution
+        self.StopExecution(None)        
         
     def DisableWhileDebuggerRunning(self):
         self._tb.EnableTool(self.STEP_ID, False)
@@ -563,7 +593,7 @@ class DebugCommandUI(wx.Panel):
             self._tb.EnableTool(self.ADD_WATCH_ID, False)
         openDocs = wx.GetApp().GetDocumentManager().GetDocuments()
         for openDoc in openDocs:  
-            if(isinstance(openDoc.GetFirstView(), CodeEditor.CodeView)): 
+            if(isinstance(openDoc, CodeEditor.CodeDocument)): 
                 openDoc.GetFirstView().GetCtrl().ClearCurrentLineMarkers() 
         if self.framesTab:   
             self.framesTab.ClearWhileRunning()
@@ -600,7 +630,7 @@ class DebugCommandUI(wx.Panel):
         self._tb.EnableTool(self.BREAK_INTO_DEBUGGER_ID, False)
         self._tb.EnableTool(self.KILL_PROCESS_ID, False)
 
-    def SynchCurrentLine(self, filename, lineNum):
+    def SynchCurrentLine(self, filename, lineNum, noArrow=False):
         # FACTOR THIS INTO DocManager
         self.DeleteCurrentLineMarkers()
         
@@ -630,13 +660,14 @@ class DebugCommandUI(wx.Panel):
             foundView.Activate()
             foundView.GotoLine(lineNum)
             startPos = foundView.PositionFromLine(lineNum)
-                
-        foundView.GetCtrl().MarkerAdd(lineNum -1, CodeEditor.CodeCtrl.CURRENT_LINE_MARKER_NUM)
+            
+        if not noArrow:        
+            foundView.GetCtrl().MarkerAdd(lineNum -1, CodeEditor.CodeCtrl.CURRENT_LINE_MARKER_NUM)
 
     def DeleteCurrentLineMarkers(self):
         openDocs = wx.GetApp().GetDocumentManager().GetDocuments()
         for openDoc in openDocs:  
-            if(isinstance(openDoc.GetFirstView(), CodeEditor.CodeView)): 
+            if(isinstance(openDoc, CodeEditor.CodeDocument)): 
                 openDoc.GetFirstView().GetCtrl().ClearCurrentLineMarkers()    
         
     def LoadFramesListXML(self, framesXML):
@@ -655,23 +686,42 @@ class DebugCommandUI(wx.Panel):
         
                        
     def StopExecution(self, event):
-        self._stopped = True
-        self.DisableAfterStop()
-        try:
-            self._callback.ServerClose()
-        except:
-            pass 
-        try:
-            if self._executor:
-                self._executor.DoStopExecution()
-                self._executor = None
-        except:
-            pass
-        self.DeleteCurrentLineMarkers()
-        DebugCommandUI.ReturnPortToPool(self._debuggerPort)
-        DebugCommandUI.ReturnPortToPool(self._guiPort)
-        DebugCommandUI.ReturnPortToPool(self._debuggerBreakPort)
+        # This is a general comment on shutdown for the running and debugged processes. Basically, the
+        # current state of this is the result of trial and error coding. The common problems were memory
+        # access violations and threads that would not exit. Making the OutputReaderThreads daemons seems
+        # to have side-stepped the hung thread issue. Being very careful not to touch things after calling
+        # process.py:ProcessOpen.kill() also seems to have fixed the memory access violations, but if there
+        # were more ugliness discovered I would not be surprised. If anyone has any help/advice, please send
+        # it on to mfryer@activegrid.com.
+        if not self._stopped:
+            self._stopped = True
+            try:
+                self.DisableAfterStop()
+            except wx._core.PyDeadObjectError:
+                pass
+            try:
+                self._callback.ShutdownServer()
+            except:
+                tp,val,tb = sys.exc_info()
+                traceback.print_exception(tp, val, tb)
 
+            try:
+                self.DeleteCurrentLineMarkers()
+            except:
+                pass
+            try:
+                DebugCommandUI.ReturnPortToPool(self._debuggerPort)
+                DebugCommandUI.ReturnPortToPool(self._guiPort)
+                DebugCommandUI.ReturnPortToPool(self._debuggerBreakPort)
+            except:
+                pass
+            try:
+                if self._executor:
+                    self._executor.DoStopExecution()
+                    self._executor = None
+            except:
+                tp,val,tb = sys.exc_info()
+                traceback.print_exception(tp, val, tb)                
     def StopAndRemoveUI(self, event):
         self.StopExecution(None)
         if self in DebugCommandUI.debuggers:
@@ -695,7 +745,7 @@ class DebugCommandUI(wx.Panel):
         self.framesTab.AppendErrorText(event.value)
         
     def OnClearOutput(self, event):
-        self.framesTab.ClearOutput()
+        self.framesTab.ClearOutput(None)
 
     def SwitchToOutputTab(self):
         self.framesTab.SwitchToOutputTab()
@@ -763,7 +813,7 @@ class BreakpointsUI(wx.Panel):
             list = self._bpListCtrl
             fileName = list.GetItem(self.currentItem, 2).GetText()
             lineNumber = list.GetItem(self.currentItem, 1).GetText()
-            self._ui.SynchCurrentLine( fileName, int(lineNumber) )  
+            self._ui.SynchCurrentLine( fileName, int(lineNumber) , noArrow=True)  
 
     def ClearBreakPoint(self, event):
         if self.currentItem >= 0:
@@ -803,7 +853,7 @@ class WatchDialog(wx.Dialog):
         self.label_4 = wx.StaticText(self, -1, ",frame.f_globals, frame.f_locals)")
         self.radio_box_1 = wx.RadioBox(self, -1, "Watch Information", choices=[WatchDialog.WATCH_ALL_FRAMES, WatchDialog.WATCH_THIS_FRAME, WatchDialog.WATCH_ONCE], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
 
-        self._okButton = wx.Button(self, wx.ID_OK, "OK", size=(75,-1))
+        self._okButton = wx.Button(self, wx.ID_OK, "OK")
         self._okButton.SetDefault()
         self._okButton.SetHelpText(_("The OK button completes the dialog"))
         def OnOkClick(event):
@@ -816,7 +866,7 @@ class WatchDialog(wx.Dialog):
             self.EndModal(wx.ID_OK)
         self.Bind(wx.EVT_BUTTON, OnOkClick, self._okButton)
             
-        self._cancelButton = wx.Button(self, wx.ID_CANCEL, _("Cancel"), size=(75,-1))
+        self._cancelButton = wx.Button(self, wx.ID_CANCEL, _("Cancel"))
         self._cancelButton.SetHelpText(_("The Cancel button cancels the dialog."))
         
         self.__set_properties()
@@ -855,7 +905,6 @@ class WatchDialog(wx.Dialog):
         box.Add(self._okButton, 0, wx.ALIGN_RIGHT|wx.ALL, 5)
         box.Add(self._cancelButton, 0, wx.ALIGN_RIGHT|wx.ALL, 5)
         sizer_1.Add(box, 1, wx.EXPAND, 0)
-        self.SetAutoLayout(True)
         self.SetSizer(sizer_1)
         self.Layout()
         
@@ -899,10 +948,10 @@ class FramesUI(wx.SplitterWindow):
         self._notebook.Hide()
         sizer3.Add(self._notebook, 1, wx.ALIGN_LEFT|wx.ALL|wx.EXPAND, 1)
         self.consoleTab = self.MakeConsoleTab(self._notebook, wx.NewId())
-        #self.inspectConsoleTab = self.MakeInspectConsoleTab(self._notebook, wx.NewId())
+        self.inspectConsoleTab = self.MakeInspectConsoleTab(self._notebook, wx.NewId())
         self.breakPointsTab = self.MakeBreakPointsTab(self._notebook, wx.NewId())
         self._notebook.AddPage(self.consoleTab, "Output")
-        #self._notebook.AddPage(self.inspectConsoleTab, "Interact")
+        self._notebook.AddPage(self.inspectConsoleTab, "Interact")
         self._notebook.AddPage(self.breakPointsTab, "Break Points")
 
         self.SetMinimumPaneSize(20)
@@ -934,25 +983,77 @@ class FramesUI(wx.SplitterWindow):
         #sizer.Fit(panel)
 
         return panel
+
+    def ReplaceLastLine(self, command):
+        line = self._interCtrl.GetLineCount() - 1
+        self._interCtrl.GotoLine(line)
+        start = self._interCtrl.GetCurrentPos()
+        self._interCtrl.SetTargetStart(start)
+        end = self._interCtrl.GetLineEndPosition(line)
+        self._interCtrl.SetTargetEnd(end)
+        self._interCtrl.ReplaceTarget(">>> " + command)
+        self._interCtrl.GotoLine(line)
+        self._interCtrl.SetSelectionStart(self._interCtrl.GetLineEndPosition(line))
+
+    def ExecuteCommand(self, command):
+        if not len(self.command_list) or not command == self.command_list[len(self.command_list) -1]:
+            self.command_list.append(command)
+            self.command_index = len(self.command_list) - 1
+        retval = self._ui._callback._debuggerServer.execute_in_frame(self._framesChoiceCtrl.GetStringSelection(), command)
+        self._interCtrl.AddText("\n" + str(retval))
+        self._interCtrl.ScrollToLine(self._interCtrl.GetLineCount())
+        # Refresh the tree view in case this command resulted in changes there. TODO: Need to reopen tree items.
+        self.PopulateTreeFromFrameMessage(self._framesChoiceCtrl.GetStringSelection())
         
     def MakeInspectConsoleTab(self, parent, id):
-        def OnEnterPressed(event):
-            print "Enter text was %s" % event.GetString()
-        def OnText(event):
-            print "Command was %s" % event.GetString()
+        self.command_list = []
+        self.command_index = 0
             
-        panel = wx.Panel(parent, id)
-        try:
+        def OnKeyPressed(event):
+            key = event.KeyCode()
+            if key == wx.WXK_DELETE or key == wx.WXK_BACK:
+                if self._interCtrl.GetLine(self._interCtrl.GetCurrentLine()) == ">>> ":
+                    return
+            elif key == wx.WXK_RETURN:
+                command = self._interCtrl.GetLine(self._interCtrl.GetCurrentLine())[4:]
+                self.ExecuteCommand(command)             
+                self._interCtrl.AddText("\n>>> ")
+                return
+            elif key == wx.WXK_UP:
+                if not len(self.command_list):
+                    return
+                self.ReplaceLastLine(self.command_list[self.command_index])
+                if self.command_index  == 0:
+                    self.command_index  = len(self.command_list) - 1
+                else:
+                    self.command_index = self.command_index - 1
+                return
+            elif key == wx.WXK_DOWN:
+                if not len(self.command_list):
+                    return
+                if self.command_index  < len(self.command_list) - 1:
+                    self.command_index = self.command_index + 1
+                else:
+                    self.command_index = 0
+                self.ReplaceLastLine(self.command_list[self.command_index])                        
+                return
+            event.Skip()
+
+        try:    
+            panel = wx.Panel(parent, id)
             sizer = wx.BoxSizer(wx.HORIZONTAL)
-            self._ictextCtrl = wx.TextCtrl(panel, wx.NewId(), style=wx.TE_MULTILINE|wx.TE_RICH|wx.HSCROLL)
-            sizer.Add(self._ictextCtrl, 1, wx.ALIGN_LEFT|wx.ALL|wx.EXPAND, 2)
-            self._ictextCtrl.Bind(wx.EVT_TEXT_ENTER, OnEnterPressed)
-            self._ictextCtrl.Bind(wx.EVT_TEXT, OnText)
+            self._interCtrl = STCTextEditor.TextCtrl(panel, wx.NewId())
+            sizer.Add(self._interCtrl, 1, wx.ALIGN_LEFT|wx.ALL|wx.EXPAND, 2)
+            self._interCtrl.SetViewLineNumbers(False)
             if wx.Platform == '__WXMSW__':
                 font = "Courier New"
             else:
                 font = "Courier"
-            self._ictextCtrl.SetDefaultStyle(wx.TextAttr(font=wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = font)))
+            self._interCtrl.SetFont(wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = font))
+            self._interCtrl.SetFontColor(wx.BLACK)
+            self._interCtrl.StyleClearAll()
+            wx.EVT_KEY_DOWN(self._interCtrl, OnKeyPressed)
+            self._interCtrl.AddText(">>> ")
             panel.SetSizer(sizer)
         except:
             tp, val, tb = sys.exc_info()
@@ -985,6 +1086,12 @@ class FramesUI(wx.SplitterWindow):
                 self.Bind(wx.EVT_MENU, self.OnView, id=self.viewID)
             item = wx.MenuItem(menu, self.viewID, "View in Dialog")
             menu.AppendItem(item)
+            if not hasattr(self, "toInteractID"):
+                self.toInteractID = wx.NewId()
+                self.Bind(wx.EVT_MENU, self.OnSendToInteract, id=self.toInteractID)
+            item = wx.MenuItem(menu, self.toInteractID, "Send to Interact")
+            menu.AppendItem(item)
+
         offset = wx.Point(x=0, y=20)
         menuSpot = event.GetPoint() + offset
         self._treeCtrl.PopupMenu(menu, menuSpot)
@@ -1009,13 +1116,33 @@ class FramesUI(wx.SplitterWindow):
         value = self._treeCtrl.GetItemText(self._introspectItem,1)
         dlg = wx.lib.dialogs.ScrolledMessageDialog(self, value, title, style=wx.DD_DEFAULT_STYLE | wx.RESIZE_BORDER)
         dlg.Show()
-
+        
+    def OnSendToInteract(self, event):
+        value = ""
+        prevItem = ""
+        for item in self._parentChain:
+            
+            if item.find(prevItem + '[') != -1:
+               value += item[item.find('['):]
+               continue
+            if value != "":
+                value = value + '.'
+            if item == 'globals':
+                item = 'globals()'
+            if item != 'locals':
+                value += item
+                prevItem = item
+        print value
+        self.ReplaceLastLine(value)
+        self.ExecuteCommand(value)
+        
     def OnWatch(self, event):
         try:
             if hasattr(self, '_parentChain'):
                 wd = WatchDialog(wx.GetApp().GetTopWindow(), "Add a Watch", self._parentChain)
             else:
                 wd = WatchDialog(wx.GetApp().GetTopWindow(), "Add a Watch", None)
+            wd.CenterOnParent()
             if wd.ShowModal() == wx.ID_OK:
                 name, text, send_frame, run_once = wd.GetSettings()
                 if send_frame:
@@ -1029,6 +1156,7 @@ class FramesUI(wx.SplitterWindow):
                 nodeList = domDoc.getElementsByTagName('watch')
                 if len(nodeList) == 1:
                     watchValue = nodeList.item(0).getAttribute("message")
+            wd.Destroy()
         except:
             tp, val, tb = sys.exc_info()
             traceback.print_exception(tp, val, tb)   
@@ -1051,6 +1179,8 @@ class FramesUI(wx.SplitterWindow):
                 tree = self._treeCtrl
                 parent = tree.GetItemParent(self._introspectItem)
                 treeNode = self.AppendSubTreeFromNode(thingToWalk, thingToWalk.getAttribute('name'), parent, insertBefore=self._introspectItem)
+                if thingToWalk.getAttribute('name').find('[') == -1:
+                    self._treeCtrl.SortChildren(treeNode)
                 self._treeCtrl.Expand(treeNode)
                 tree.Delete(self._introspectItem)
         except:
@@ -1066,6 +1196,7 @@ class FramesUI(wx.SplitterWindow):
         tree = self._treeCtrl  
         root = self._root   
         tree.DeleteChildren(root)
+        self._interCtrl.Enable(False)
    
         #tree.Hide()
         
@@ -1088,6 +1219,8 @@ class FramesUI(wx.SplitterWindow):
         
     def LoadFramesListXML(self, framesXML):
         wx.GetApp().GetTopWindow().SetCursor(wx.StockCursor(wx.CURSOR_WAIT))
+        self._interCtrl.Enable(True)
+
         try:
             domDoc = parseString(framesXML)
             list = self._framesChoiceCtrl
@@ -1103,6 +1236,7 @@ class FramesUI(wx.SplitterWindow):
                 frame_count += 1
             index = len(self._stack) - 1
             list.SetSelection(index) 
+
             node = self._stack[index]
             self.currentItem = index
             self.PopulateTreeFromFrameNode(node)
@@ -1121,13 +1255,20 @@ class FramesUI(wx.SplitterWindow):
 
         
     def ListItemSelected(self, event):
-        message = event.GetString()
+        self.PopulateTreeFromFrameMessage(event.GetString())
+        self.OnSyncFrame(None)
+        
+    def PopulateTreeFromFrameMessage(self, message):    
         index = 0
         for node in self._stack:
             if node.getAttribute("message") == message:
+                binType = self._ui._callback._debuggerServer.request_frame_document(message)
+                xmldoc = bz2.decompress(binType.data)
+                domDoc = parseString(xmldoc)
+                nodeList = domDoc.getElementsByTagName('frame')
                 self.currentItem = index
-                self.PopulateTreeFromFrameNode(node)
-                self.OnSyncFrame(None)
+                if len(nodeList):
+                    self.PopulateTreeFromFrameNode(nodeList[0])
                 return
             index = index + 1
                         
@@ -1146,7 +1287,8 @@ class FramesUI(wx.SplitterWindow):
             if not firstChild:
                 firstChild = treeNode
         tree.Expand(root)
-        tree.Expand(firstChild)
+        if firstChild:
+            tree.Expand(firstChild)
         self._p2.FitInside()
         
     def IntrospectCallback(self, event):
@@ -1189,7 +1331,8 @@ class FramesUI(wx.SplitterWindow):
                 if intro == "True":
                     tree.SetItemHasChildren(n, True)
                     tree.SetPyData(n, "Introspect")
-
+        if name.find('[') == -1:
+            self._treeCtrl.SortChildren(treeNode)
         return treeNode
         
     def StripOuterSingleQuotes(self, string):
@@ -1252,7 +1395,13 @@ class DebuggerView(Service.ServiceView):
     
     def OnToolClicked(self, event):
         self.GetFrame().ProcessEvent(event)
-    
+        
+    def ProcessUpdateUIEvent(self, event):
+        return False
+        
+    def ProcessEvent(self, event):
+        return False
+
     #------------------------------------------------------------------------------
     # Class methods
     #-----------------------------------------------------------------------------
@@ -1396,9 +1545,9 @@ class DebuggerCallback:
     def start(self):
         self._serverHandlerThread.start()
     
-    def ServerClose(self):
-        rbt = RequestBreakThread(self._breakServer, kill=True)
-        rbt.start()
+    def ShutdownServer(self):
+        #rbt = RequestBreakThread(self._breakServer, kill=True)
+        #rbt.start()
         self.setWaiting(False)
         if self._serverHandlerThread:
             self._serverHandlerThread.AskToStop()
@@ -1410,29 +1559,21 @@ class DebuggerCallback:
                 
     def SingleStep(self):
         self._debuggerUI.DisableWhileDebuggerRunning()
-        #dot = DebuggerOperationThread(self._debuggerServer.set_step)
-        #dot.start()
         self._debuggerServer.set_step() # Figure out where to set allowNone
         self.waitForRPC()
 
     def Next(self):
         self._debuggerUI.DisableWhileDebuggerRunning()
-        #dot = DebuggerOperationThread(self._debuggerServer.set_next)
-        #dot.start()
         self._debuggerServer.set_next()
         self.waitForRPC()
         
     def Continue(self):
         self._debuggerUI.DisableWhileDebuggerRunning()
-        #dot = DebuggerOperationThread(self._debuggerServer.set_continue)
-        #dot.start()
         self._debuggerServer.set_continue()
         self.waitForRPC()
         
     def Return(self):
         self._debuggerUI.DisableWhileDebuggerRunning()
-        #dot = DebuggerOperationThread(self._debuggerServer.set_return)
-        #dot.start()
         self._debuggerServer.set_return()
         self.waitForRPC()
         
@@ -1498,7 +1639,6 @@ class DebuggerCallback:
         if _VERBOSE: print "+"*40
         
 class DebuggerService(Service.Service):
-    executors = []
 
     #----------------------------------------------------------------------------
     # Constants
@@ -1508,12 +1648,7 @@ class DebuggerService(Service.Service):
     RUN_ID = wx.NewId()
     DEBUG_ID = wx.NewId()
     DEBUG_WEBSERVER_ID = wx.NewId()
-
-    def KillAllRunningProcesses():
-        execs = DebuggerService.executors
-        for executor in execs:
-            executor.DoStopExecution()
-    KillAllRunningProcesses = staticmethod(KillAllRunningProcesses)
+    RUN_WEBSERVER_ID = wx.NewId()
             
     def ComparePaths(first, second):
         one = DebuggerService.ExpandPath(first)
@@ -1530,7 +1665,8 @@ class DebuggerService(Service.Service):
             try:
                 return win32api.GetLongPathName(path)
             except:
-                print "Cannot get long path for %s" % path
+                if _VERBOSE:
+                    print "Cannot get long path for %s" % path
                 
         return path
         
@@ -1594,6 +1730,9 @@ class DebuggerService(Service.Service):
                 debuggerMenu.Append(DebuggerService.DEBUG_WEBSERVER_ID, _("Debug Internal Web Server"), _("Debugs the internal webservier"))
                 wx.EVT_MENU(frame, DebuggerService.DEBUG_WEBSERVER_ID, frame.ProcessEvent)
                 wx.EVT_UPDATE_UI(frame, DebuggerService.DEBUG_WEBSERVER_ID, frame.ProcessUpdateUIEvent)
+                debuggerMenu.Append(DebuggerService.RUN_WEBSERVER_ID, _("Restart Internal Web Server"), _("Restarts the internal webservier"))
+                wx.EVT_MENU(frame, DebuggerService.RUN_WEBSERVER_ID, frame.ProcessEvent)
+                wx.EVT_UPDATE_UI(frame, DebuggerService.RUN_WEBSERVER_ID, frame.ProcessUpdateUIEvent)
             
             debuggerMenu.AppendSeparator()
             
@@ -1608,6 +1747,11 @@ class DebuggerService(Service.Service):
             
         viewMenuIndex = menuBar.FindMenu(_("&Project"))
         menuBar.Insert(viewMenuIndex + 1, debuggerMenu, _("&Run"))
+        
+        toolBar.AddSeparator()
+        toolBar.AddTool(DebuggerService.RUN_ID, getRunningManBitmap(), shortHelpString = _("Run"), longHelpString = _("Run"))
+        toolBar.AddTool(DebuggerService.DEBUG_ID, getDebuggingManBitmap(), shortHelpString = _("Debug"), longHelpString = _("Debug"))
+        toolBar.Realize()
 
         return True
 
@@ -1641,6 +1785,9 @@ class DebuggerService(Service.Service):
         elif an_id == DebuggerService.DEBUG_WEBSERVER_ID:
             self.OnDebugWebServer(event)
             return True
+        elif an_id == DebuggerService.RUN_WEBSERVER_ID:
+            self.OnRunWebServer(event)
+            return True
         return False
         
     def ProcessUpdateUIEvent(self, event):
@@ -1677,13 +1824,13 @@ class DebuggerService(Service.Service):
             return
         self.ShowWindow(True)
         projectService = wx.GetApp().GetService(ProjectEditor.ProjectService)
-        project = projectService.GetView().GetDocument()
         try:
             dlg = CommandPropertiesDialog(self.GetView().GetFrame(), 'Debug Python File', projectService, None, pythonOnly=True, okButtonName="Debug", debugging=True)
         except:
             return
+        dlg.CenterOnParent()
         if dlg.ShowModal() == wx.ID_OK:
-            fileToDebug, initialArgs, startIn, isPython, environment = dlg.GetSettings()
+            projectPath, fileToDebug, initialArgs, startIn, isPython, environment = dlg.GetSettings()
             dlg.Destroy()
         else:
             dlg.Destroy()
@@ -1714,14 +1861,20 @@ class DebuggerService(Service.Service):
         wsService = wx.GetApp().GetService(WebServerService.WebServerService)
         fileName, args = wsService.StopAndPrepareToDebug()
         try:
-            page = DebugCommandUI(Service.ServiceView.bottomTab, -1, str(fileName), self)
+            page = DebugCommandUI(Service.ServiceView.bottomTab, -1, fileName, self)
             count = Service.ServiceView.bottomTab.GetPageCount()
             Service.ServiceView.bottomTab.AddPage(page, _("Debugging: Internal WebServer"))
             Service.ServiceView.bottomTab.SetSelection(count)
             page.Execute(args, startIn=os.getcwd(), environment=os.environ)
         except:
             pass
-         
+            
+    def OnRunWebServer(self, event):
+        if not Executor.GetPythonExecutablePath():
+            return
+        import WebServerService
+        wsService = wx.GetApp().GetService(WebServerService.WebServerService)
+        wsService.ShutDownAndRestart()                
                                
     def HasAnyFiles(self):
         docs = wx.GetApp().GetDocumentManager().GetDocuments()
@@ -1748,13 +1901,16 @@ class DebuggerService(Service.Service):
                           _("Debug"),
                           wx.YES_NO|wx.ICON_QUESTION
                           )
+            yesNoMsg.CenterOnParent()
             if yesNoMsg.ShowModal() == wx.ID_YES:
                 docs = wx.GetApp().GetDocumentManager().GetDocuments()
                 for doc in docs:
                     doc.Save()
+            yesNoMsg.Destroy()
 
     def OnExit(self):
         DebugCommandUI.ShutdownAllDebuggers()
+        RunCommandUI.ShutdownAllRunners()
         
     def OnRunProject(self, event):
         if _WINDOWS and not _PYWIN32_INSTALLED:
@@ -1763,15 +1919,13 @@ class DebuggerService(Service.Service):
         if not Executor.GetPythonExecutablePath():
             return
         projectService = wx.GetApp().GetService(ProjectEditor.ProjectService)
-        project = projectService.GetView().GetDocument()
         try:
             dlg = CommandPropertiesDialog(self.GetView().GetFrame(), 'Run', projectService, None)
         except:
             return
+        dlg.CenterOnParent()
         if dlg.ShowModal() == wx.ID_OK:
-            fileToRun, initialArgs, startIn, isPython, environment = dlg.GetSettings()
-            
-
+            projectPath, fileToRun, initialArgs, startIn, isPython, environment = dlg.GetSettings()
             dlg.Destroy()
         else:
             dlg.Destroy()
@@ -1779,7 +1933,12 @@ class DebuggerService(Service.Service):
         self.PromptToSaveFiles()
         # This will need to change when we can run more than .py and .bpel files.
         if not isPython:
-            projectService.RunProcessModel(fileToRun)
+            projects = projectService.FindProjectByFile(projectPath)
+            if not projects:
+                return
+            project = projects[0]
+            deployFilePath = project.GenerateDeployment()
+            projectService.RunProcessModel(fileToRun, project.GetAppInfo().language, deployFilePath)
             return
             
         self.ShowWindow(True)
@@ -1799,10 +1958,16 @@ class DebuggerService(Service.Service):
             fileName = wx.GetApp().GetDocumentManager().GetCurrentDocument().GetFilename()
             if line < 0:
                 line = view.GetCtrl().GetCurrentLine()
+        else:
+            view = None
         if  self.BreakpointSet(fileName, line + 1):
             self.ClearBreak(fileName, line + 1)
+            if view:
+                view.GetCtrl().Refresh()
         else:
             self.SetBreak(fileName, line + 1)
+            if view:
+                view.GetCtrl().Refresh()
         # Now refresh all the markers icons in all the open views.
         self.ClearAllBreakpointMarkers()
         self.SetAllBreakpointMarkers()    
@@ -1837,6 +2002,10 @@ class DebuggerService(Service.Service):
         else:
             return self._masterBPDict[expandedName] 
 
+    def SetBreakpointList(self, fileName, bplist):
+        expandedName = DebuggerService.ExpandPath(fileName)
+        self._masterBPDict[expandedName] = bplist
+        
     def BreakpointSet(self, fileName, line):
         expandedName = DebuggerService.ExpandPath(fileName)
         if not self._masterBPDict.has_key(expandedName):
@@ -1875,16 +2044,20 @@ class DebuggerService(Service.Service):
     def ClearAllBreakpointMarkers(self):
         openDocs = wx.GetApp().GetDocumentManager().GetDocuments()
         for openDoc in openDocs:  
-            if(isinstance(openDoc.GetFirstView(), CodeEditor.CodeView)): 
+            if isinstance(openDoc, CodeEditor.CodeDocument): 
                 openDoc.GetFirstView().MarkerDeleteAll(CodeEditor.CodeCtrl.BREAKPOINT_MARKER_NUM) 
-
+                
+    def UpdateBreakpointsFromMarkers(self, view, fileName):
+        newbpLines = view.GetMarkerLines(CodeEditor.CodeCtrl.BREAKPOINT_MARKER_NUM)
+        self.SetBreakpointList(fileName, newbpLines)
+        
     def GetMasterBreakpointDict(self):
         return self._masterBPDict
         
     def SetAllBreakpointMarkers(self):
         openDocs = wx.GetApp().GetDocumentManager().GetDocuments()
         for openDoc in openDocs:  
-            if(isinstance(openDoc.GetFirstView(), CodeEditor.CodeView)): 
+            if(isinstance(openDoc, CodeEditor.CodeDocument)): 
                 self.SetCurrentBreakpointMarkers(openDoc.GetFirstView())
             
     def SetCurrentBreakpointMarkers(self, view):
@@ -1950,6 +2123,11 @@ class DebuggerOptionsPanel(wx.Panel):
         config.Write("DebuggerHostName", self._LocalHostTextCtrl.GetValue())
         if self._PortNumberTextCtrl.IsInBounds():
             config.WriteInt("DebuggerStartingPort", self._PortNumberTextCtrl.GetValue())
+            
+
+    def GetIcon(self):
+        return getContinueIcon()
+
 
 class CommandPropertiesDialog(wx.Dialog):
     
@@ -1968,10 +2146,8 @@ class CommandPropertiesDialog(wx.Dialog):
         if not self._projectNameList:
             wx.MessageBox(_("To run or debug you must have an open runnable file or project containing runnable files. Use File->Open to open the file you wish to run or debug."), _("Nothing to Run"))
             raise BadBadBad
-        if _WINDOWS:
-            wx.Dialog.__init__(self, parent, -1, title)
-        else:
-            wx.Dialog.__init__(self, parent, -1, title, size=(390,270)) 
+
+        wx.Dialog.__init__(self, parent, -1, title)
            
         projStaticText = wx.StaticText(self, -1, _("Project:")) 
         fileStaticText = wx.StaticText(self, -1, _("File:")) 
@@ -1980,46 +2156,43 @@ class CommandPropertiesDialog(wx.Dialog):
         pythonPathStaticText = wx.StaticText(self, -1, _("PYTHONPATH:"))
         postpendStaticText = _("Postpend win32api path")
         cpPanelBorderSizer = wx.BoxSizer(wx.VERTICAL)
-        self._projList = wx.Choice(self, -1, (200,-1), choices=self._projectNameList)
+        self._projList = wx.Choice(self, -1, choices=self._projectNameList)
         self.Bind(wx.EVT_CHOICE, self.EvtListBox, self._projList)
         HALF_SPACE = 5
-        flexGridSizer = wx.FlexGridSizer(cols = 3, vgap = 10, hgap = 10)
+        GAP = HALF_SPACE
+        if wx.Platform == "__WXMAC__":
+            GAP = 10
+        flexGridSizer = wx.GridBagSizer(GAP, GAP)
         
-        flexGridSizer.Add(projStaticText, 0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
-        flexGridSizer.Add(self._projList, 1, flag=wx.EXPAND)
-        flexGridSizer.Add(wx.StaticText(parent, -1, ""), 0)
+        flexGridSizer.Add(projStaticText, (0,0), flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
+        flexGridSizer.Add(self._projList, (0,1), (1,2), flag=wx.EXPAND)
         
-        flexGridSizer.Add(fileStaticText, 0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
-        self._fileList = wx.Choice(self, -1, (200,-1))
+        flexGridSizer.Add(fileStaticText, (1,0), flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
+        self._fileList = wx.Choice(self, -1)
         self.Bind(wx.EVT_CHOICE, self.OnFileSelected, self._fileList)
-        flexGridSizer.Add(self._fileList, 1, flag=wx.EXPAND)
-        flexGridSizer.Add(wx.StaticText(parent, -1, ""), 0)
+        flexGridSizer.Add(self._fileList, (1,1), (1,2), flag=wx.EXPAND)
         
         config = wx.ConfigBase_Get()
         self._lastArguments = config.Read("LastRunArguments")
         self._argsEntry = wx.TextCtrl(self, -1, str(self._lastArguments))
         self._argsEntry.SetToolTipString(str(self._lastArguments))
 
-        flexGridSizer.Add(argsStaticText, 0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
-        flexGridSizer.Add(self._argsEntry, 1, flag=wx.EXPAND)
-        flexGridSizer.Add(wx.StaticText(parent, -1, ""), 0)
+        flexGridSizer.Add(argsStaticText, (2,0), flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
+        flexGridSizer.Add(self._argsEntry, (2,1), (1,2), flag=wx.EXPAND)
         
-        flexGridSizer.Add(startInStaticText, 0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
+        flexGridSizer.Add(startInStaticText, (3,0), flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
         self._lastStartIn = config.Read("LastRunStartIn")
         if not self._lastStartIn:
             self._lastStartIn = str(os.getcwd())
         self._startEntry = wx.TextCtrl(self, -1, self._lastStartIn)
         self._startEntry.SetToolTipString(self._lastStartIn)
-        def TextChanged2(event):
-            self._startEntry.SetToolTipString(event.GetString())
-        self.Bind(wx.EVT_TEXT, TextChanged2, self._startEntry)
 
-        flexGridSizer.Add(self._startEntry, 1, wx.EXPAND)
+        flexGridSizer.Add(self._startEntry, (3,1), flag=wx.EXPAND)
         self._findDir = wx.Button(self, -1, _("Browse..."))
         self.Bind(wx.EVT_BUTTON, self.OnFindDirClick, self._findDir)
-        flexGridSizer.Add(self._findDir, 0, wx.RIGHT, 10)
+        flexGridSizer.Add(self._findDir, (3,2))
         
-        flexGridSizer.Add(pythonPathStaticText, 0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
+        flexGridSizer.Add(pythonPathStaticText, (4,0), flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
         if os.environ.has_key('PYTHONPATH'):
             startval = os.environ['PYTHONPATH']
         else:
@@ -2027,34 +2200,29 @@ class CommandPropertiesDialog(wx.Dialog):
         self._lastPythonPath = config.Read("LastPythonPath", startval)
         self._pythonPathEntry = wx.TextCtrl(self, -1, self._lastPythonPath)
         self._pythonPathEntry.SetToolTipString(self._lastPythonPath)
-        flexGridSizer.Add(self._pythonPathEntry, 1, wx.EXPAND)
-        flexGridSizer.Add(wx.StaticText(parent, -1, ""), 0)
-        flexGridSizer.Add(wx.StaticText(parent, -1, ""), 0)
-        if debugging:
+        flexGridSizer.Add(self._pythonPathEntry, (4,1), (1,2), flag=wx.EXPAND)
+        
+        if debugging and _WINDOWS:
             self._postpendCheckBox = wx.CheckBox(self, -1, postpendStaticText)
             checked = bool(config.ReadInt("PythonPathPostpend", 1))
             self._postpendCheckBox.SetValue(checked)
-            flexGridSizer.Add(self._postpendCheckBox, 1, wx.EXPAND)
-        flexGridSizer.Add(wx.StaticText(parent, -1, ""), 0)
-        cpPanelBorderSizer.Add(flexGridSizer, 0, wx.ALL, 10)
+            flexGridSizer.Add(self._postpendCheckBox, (5,1), flag=wx.EXPAND)
+        cpPanelBorderSizer.Add(flexGridSizer, 0, flag=wx.ALL, border=10)
         
-        box = wx.BoxSizer(wx.HORIZONTAL)
+        box = wx.StdDialogButtonSizer()
         self._okButton = wx.Button(self, wx.ID_OK, okButtonName)
         self._okButton.SetDefault()
         self._okButton.SetHelpText(_("The ") + okButtonName + _(" button completes the dialog"))
-        box.Add(self._okButton, 0, wx.ALIGN_RIGHT|wx.ALL, 5)
+        box.AddButton(self._okButton)
         self.Bind(wx.EVT_BUTTON, self.OnOKClick, self._okButton)
         btn = wx.Button(self, wx.ID_CANCEL, _("Cancel"))
         btn.SetHelpText(_("The Cancel button cancels the dialog."))
-        box.Add(btn, 0, wx.ALIGN_RIGHT|wx.ALL, 5)
-        cpPanelBorderSizer.Add(box, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 5)
+        box.AddButton(btn)
+        box.Realize()
+        cpPanelBorderSizer.Add(box, 0, flag=wx.ALIGN_RIGHT|wx.ALL, border=5)
         
         self.SetSizer(cpPanelBorderSizer)
-        if _WINDOWS:
-            self.GetSizer().Fit(self)
-        
-        self.Layout()
-        
+                
         # Set up selections based on last values used.
         self._fileNameList = None
         self._selectedFileIndex = 0
@@ -2069,6 +2237,9 @@ class CommandPropertiesDialog(wx.Dialog):
         self._selectedProjectIndex = selectedIndex
         self._selectedProjectDocument = self._projectDocumentList[selectedIndex]
         self.PopulateFileList(self._selectedProjectDocument, lastFile)
+
+        cpPanelBorderSizer.Fit(self)
+
             
     def OnOKClick(self, event):
         startIn = self._startEntry.GetValue()
@@ -2094,6 +2265,7 @@ class CommandPropertiesDialog(wx.Dialog):
         self.EndModal(wx.ID_OK)
             
     def GetSettings(self):  
+        projectPath = self._selectedProjectDocument.GetFilename()
         filename = self._fileNameList[self._selectedFileIndex]
         args = self._argsEntry.GetValue() 
         startIn = self._startEntry.GetValue()
@@ -2108,7 +2280,7 @@ class CommandPropertiesDialog(wx.Dialog):
         else:
             env['PYTHONPATH'] = self._pythonPathEntry.GetValue()
             
-        return filename, args, startIn, isPython, env
+        return projectPath, filename, args, startIn, isPython, env
                       
     def OnFileSelected(self, event):
         self._selectedFileIndex = self._fileList.GetSelection()
@@ -2130,16 +2302,17 @@ class CommandPropertiesDialog(wx.Dialog):
             self._argsEntry.SetValue(self._lastArguments)  
                 
             
-
     def OnFindDirClick(self, event):
         dlg = wx.DirDialog(self, "Choose a starting directory:", self._startEntry.GetValue(),
                           style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
 
+        dlg.CenterOnParent()
         if dlg.ShowModal() == wx.ID_OK:
             self._startEntry.SetValue(dlg.GetPath())
             
         dlg.Destroy() 
            
+
     def EvtListBox(self, event):
         if event.GetString():
             index = self._projectNameList.index(event.GetString())
@@ -2240,19 +2413,20 @@ def getBreakIcon():
     return wx.IconFromBitmap(getBreakBitmap())
 
 #----------------------------------------------------------------------
+
 def getClearOutputData():
     return \
 '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
 \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
-\x00\x00\xb4IDAT8\x8d\xa5\x92\xdd\r\x03!\x0c\x83\xbf\xa0n\xd4\x9d\xda5\xb81\
-\xbaS\xbb\x12\xee\x03?\xe5\x08\xe5N\xba\xbc Db\xec\xd8p\xb1l\xb8\xa7\x83\xfe\
-\xb0\x02H\x92F\xc0_\xa3\x99$\x99\x99\xedznc\xe36\x81\x88\x98"\xb2\x02\xa2\
-\x1e\xc4Q\x9aUD\x161\xcd\xde\x1c\x83\x15\x084)\x8d\xc5)\x06\xab\xaaZ\x92\xee\
-\xce\x11W\xdbGD\x0cIT\x06\xe7\x00\xdeY\xfe\xcc\x89\x06\xf0\xf2\x99\x00\xe0\
-\x91\x7f\xab\x83\xed\xa4\xc8\xafK\x0c\xcf\x92\x83\x99\x8d\xe3p\xef\xe4\xa1\
-\x0b\xe57j\xc8:\x06\t\x08\x87.H\xb2n\xa8\xc9\xa9\x12vQ\xfeG"\xe3\xacw\x00\
-\x10$M\xd3\x86_\xf0\xe5\xfc\xb4\xfa\x02\xcb\x13j\x10\xc5\xd7\x92D\x00\x00\
-\x00\x00IEND\xaeB`\x82' 
+\x00\x00\xb7IDAT8\x8d\xa5\x93\xdd\x11\xc3 \x0c\x83%`\xa3\xee\xd4\xaeA\xc6\
+\xe8N\xedF%\xea\x03\t\x81\xf0\x97\xbb\xf8%G\xce\xfe\x90eC\x1a\x8b;\xe1\xf2\
+\x83\xd6\xa0Q2\x8de\xf5oW\xa05H\xea\xd7\x93\x84$\x18\xeb\n\x88;\'.\xd5\x1d\
+\x80\x07\xe1\xa1\x1d\xa2\x1cbF\x92\x0f\x80\xe0\xd1 \xb7\x14\x8c \x00*\x15\
+\x97\x14\x8c\x8246\x1a\xf8\x98\'/\xdf\xd8Jn\xe65\xc0\xa7\x90_L"\x01\xde\x9d\
+\xda\xa7\x92\xfb\xc5w\xdf\t\x07\xc4\x05ym{\xd0\x1a\xe3\xb9xS\x81\x04\x18\x05\
+\xc9\x04\xc9a\x00Dc9\x9d\x82\xa4\xbc\xe8P\xb2\xb5P\xac\xf2\x0c\xd4\xf5\x00\
+\x88>\xac\xe17\x84\xe4\xb9G\x8b7\x9f\xf3\x1fsUl^\x7f\xe7y\x0f\x00\x00\x00\
+\x00IEND\xaeB`\x82' 
 
 def getClearOutputBitmap():
     return BitmapFromImage(getClearOutputImage())
@@ -2295,13 +2469,15 @@ def getContinueData():
     return \
 '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
 \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
-\x00\x00\x9eIDAT8\x8d\xbd\x92\xd1\r\x83@\x0cC\xed\x8a\x11X\xac\x1b\xddF,\xd6\
-\x11\x90\xdc\x0f\x9a\x93s)\x14Z\xa9\x91\x10\n\x97\xbc\xd89\x80?\x84\x1a\xa4\
-\x83\xfc\x1c$\x1e)7\xdf<Y0\xaf\x0b\xe6\xf5\x1d\xa1\xb5\x13C\x03 !\xaa\xfd\
-\xed\n:mr\xc0\x1d\x8f\xc9\x9a!\t$\xe5\xd3I\xe2\xe5B$\x99\x00[\x01\xe8\xc5\
-\xd9G\xfaN`\xd8\x81I\xed\x8c\xb19\x94\x8d\xcbL\x00;t\xcf\x9fwPh\xdb\x0e\xe8\
-\xd3,\x17\x8b\xc7\x9d\xbb>\x8a \xec5\x94\tc\xc4\x12\xab\x94\xeb\x7fkWr\xc9B%\
-\xfc\xd2\xfcM<\x01\xf6tn\x12O3c\xe6\x00\x00\x00\x00IEND\xaeB`\x82' 
+\x00\x00\xcdIDAT8\x8d\xa5\x93\xd1\r\xc20\x0cD\xef\xec,\xc0b\x88\x8d`$\x06Cb\
+\x81\xc6\xc7GI\xeb\x94RZq?U"\xdby\xe7SIs\xfc#\xfbU\xa0\xa8\xba\xc6\xa0og\xee\
+!P\xd4y\x80\x04\xf3\xc2U\x82{\x9ct\x8f\x93\xb0\xa2\xdbm\xf5\xba\'h\xcdg=`\
+\xeeTT\xd1\xc6o& \t\x9a\x13\x00J\x9ev\xb1\'\xa3~\x14+\xbfN\x12\x92\x00@\xe6\
+\x85\xdd\x00\x000w\xe6\xe2\xde\xc7|\xdf\x08\xba\x1d(\xaa2n+\xca\xcd\x8d,\xea\
+\x98\xc4\x07\x01\x00D\x1dd^\xa8\xa8j\x9ew\xed`\xa9\x16\x99\xde\xa6G\x8b\xd3Y\
+\xe6\x85]\n\r\x7f\x99\xf5\x96Jnlz#\xab\xdb\xc1\x17\x19\xb0XV\xc2\xdf\xa3)\
+\x85<\xe4\x88\x85.F\x9a\xf3H3\xb0\xf3g\xda\xd2\x0b\xc5_|\x17\xe8\xf5R\xd6\
+\x00\x00\x00\x00IEND\xaeB`\x82' 
 
 def getContinueBitmap():
     return BitmapFromImage(getContinueImage())
@@ -2361,12 +2537,12 @@ def getStepInIcon():
 #----------------------------------------------------------------------
 def getStopData():
     return \
-"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
+'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
 \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
-\x00\x00FIDAT8\x8d\xed\x91\xc1\t\xc00\x0c\x03O!\x0b\xa9\xfb\xef\xa6\xfcB\xa1\
-N\t\xf4Wr\xa0\x8f\xb1\x0f\x81\xe1\x97\xe4-\xb6}_V%\xc8\xc2, \t\x92\xe6]\xfbZ\
-\xf7\x08\xa0W\xc3\xea5\xdb\rl_IX\xe5\xf0d\x00\xfa\x8d#\x7f\xc4\xf7'\xab\x00\
-\x00\x00\x00IEND\xaeB`\x82" 
+\x00\x00QIDAT8\x8d\xdd\x93A\n\xc00\x08\x04g\xb5\xff\x7fq\x13sn\xda&\x01\x0b\
+\xa5]\xf0"\xec(.J\xe6dd)\xf7\x13\x80\xadoD-12\xc8\\\xd3\r\xe2\xa6\x00j\xd9\
+\x0f\x03\xde\xbf\xc1\x0f\x00\xa7\x18\x01t\xd5\\\x05\xc8\\}T#\xe9\xfb\xbf\x90\
+\x064\xd8\\\x12\x1fQM\xf5\xd9\x00\x00\x00\x00IEND\xaeB`\x82' 
 
 def getStopBitmap():
     return BitmapFromImage(getStopImage())
@@ -2422,3 +2598,76 @@ def getAddWatchImage():
 
 def getAddWatchIcon():
     return wx.IconFromBitmap(getAddWatchBitmap())
+    
+#----------------------------------------------------------------------
+def getRunningManData():
+    return \
+'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
+\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
+\x00\x01\x86IDAT8\x8d\xa5\x93\xb1K\x02Q\x1c\xc7\xbf\xcf\x9a\x1bZl\x88\xb4\
+\x04\x83\x10\xa2\x96\xc0A\xa8\x96\x96\xf4h\xe9\xf0\x1f\xd0\xcd(Bpi\x13nH\xb2\
+%\x9d\x1a"\xb9)\xb4\x16i\x10\n\x13MA\x84\xa3&\xa1\xa1A\xa1E\xbdw\x97\xa2\xbd\
+\x06\xf1(\xef,\xac\xef\xf6x\xdf\xf7}\x9f\xdf\x97\xf7\x081M\xe0?\x9a\xfc\xcd \
+\\\xdc2\x99\xb6A[\x14\x91C\x9e\x8c\x1d\x00\x00\xd5\xa7*\x9a\x8a\xfa7\x82u\
+\xfb\x14dj\x03mQ\xc3}\xf2\xb5\x83\xc7B\x9e\x89\xf7/\xda\xba\xd1\x94\x01\x00j\
+CF\xe2t\xef\x1b>\x1f\x8c3Q\xf0\x11\xd3p\xa2yf\x1a\xbc\xcb\n\xdee\x85\xdd>\
+\x07\xb5!C\xe9\xb4\xb1\xe9=b\x03\x8fc\xc3\xcf\xbcN\xb3\x9e`@\x11\xb9\xaa`\
+\x7fg\x19\'\x97y\xd8\x96\xfa\xf8\x95\xf23d\xa5O4\xbfh\x87(\xf8\x88a\xc0 $|~\
+\x87n\xf7\x03\xaa\xf2\x8e\xc0\xee\n\x00 \x91\xab\xc3\xeb4\xc3\xed\xe1\xb4qF\
+\x96\xb8`\xb3h\xb7\xa6Jo\xa0\x9d\x1eD\xc1G\xc4!\x9f\xae\x03\x00\xa8\xd5jh4e\
+\r\xb9\xf0P\x82T,\x83\xf3\x0bl\xd8k\x18\xe0\xf6p\x84vz\xa0M\x8aB\xf2\x98\x84\
+\x03[\xb0.XP\xcafu^m\x04>\x18\xd7\x9aM\xe4\xea\xba\xc0x\xec\x8c\xa9\xca*^\
+\xa5\x1b}\xc0u*\xc9B\xd14\x12\xe8\x97%\x15\xcbF`\xdaH\xba\x80P4\r)\x13#R\xc6\
+\xf0\xdc\x8f2\x01\x80\x94\x89\xe9>\xc9(\xcd:\xb6\xd9\x1aw\xa0\x95i\xf8\x0e\
+\xc6\xd1\'\'\x86\xa2\xd5\x8d \xbe@\x00\x00\x00\x00IEND\xaeB`\x82' 
+
+def getRunningManBitmap():
+    return BitmapFromImage(getRunningManImage())
+
+def getRunningManImage():
+    stream = cStringIO.StringIO(getRunningManData())
+    return ImageFromStream(stream)
+
+def getRunningManIcon():
+    icon = EmptyIcon()
+    icon.CopyFromBitmap(getRunningManBitmap())
+    return icon
+
+#----------------------------------------------------------------------
+def getDebuggingManData():
+    return \
+'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
+\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
+\x00\x01\xafIDAT8\x8d\x8d\x93\xbfK[Q\x14\xc7?7\n:\t\xb5SA\xc1?@\xc1A\x9c,%\
+\xd0\xa9\x83\xb5\x98!(b\t\xbc\xa7q("m\x1c\n5V]D\xd4-\xf8\x83\xa7\xa2\t\xa1\
+\xa6\xed$8\x08\x92\xa1\x8b\x14A\xd0YB"\xa4\xf4\x87\x90\x97K\xa8\xcb\xed\xf0\
+\xc8m\xae\xfa\xd4\x03\x07.\xe7\x9e\xf3\xfd\x9e\x9f\x88@\x1d\xb5\xba\x94\xca\
+\xaa\xeb\xb6\xbb4\xc0\x03d&\xb1\xa7\xfc\xfe\x0c\x80L\xdaQ\xd2\xad\x90I;F\x80\
+++\xbe\xe0bve\xdf\xd7y\xfemH\xc4\x162\xaa\xbb\xa5D(\x1c\x11\xb7\x02\x88@\x9d\
+f?*4\xd1\xf6\xa2\x0f\x80\x93\xf4\x8e\xe1\xb8\xf2\xf1\xb5\x18\x9cH(\x80\xe4bT\
+\x83\xd5W\x1f\xa1pD\x8c|\xd8T\x00\xdf\xd6\xd7\xe8\x1f\xb3tp\xf1\n^\xfe\xf8\
+\xa5^u7\x00P\x1eYP\xd2\x95\x1c\xa4\xa6\x84\x18\x8do\xab*C&\xed\xa8\xafG\x7f\
+\xe9\x1f\xb3x\xdc\x08\xad\x8f \x7f\tg%\xf8Y\x82\xe3\x8de\x86\x82\xcdF9\xba\
+\x84\xc1\x89\x84*K\t\xc0\xf0\xbbq:\x9f\xfcO\x7f?\xe7\x01\x9c\xff\x86Br\x8e\
+\x83\xd4\x94\x06\xd0SH.F\xc5P\xb0\x19\xe9z \xf9KOmkN\x07\x03\x14/r\xb4?\x8b\
+\xe8\xc6\xeb\x1e\x00l\x1f\xfe\xd15\x17\xaf<\xdb\xd37\xef\xd9\x9d\xb4\xe9\x8a\
+\xadj\xbfx\xb4\x878(#\x03\x00\xe9JF{[\xf92\xeb\xb1V\x99\xbbb\xab|\x9f\xb7\
+\x8d\xa9\x9cf\x1dq\x9au\xc4\x8dM\x0c\x85#\xa2x\x91cw\xd2\xd6i\x83\trk\x13\
+\x9f\x0fL\xab\xda\xe6\xd4\xd6Y+\xf1h\x8f\xb9T~G\xd2\x11\xb4\xd4\xe7O[\xf7\
+\x1e\xd6\x9d\xc7\xe4\xb7\xbe\x86\xf8\xb1?\xf4\x9c\xff\x01\xbe\xe9\xaf\x96\
+\xf0\x7fPA\x00\x00\x00\x00IEND\xaeB`\x82' 
+
+def getDebuggingManBitmap():
+    return BitmapFromImage(getDebuggingManImage())
+
+def getDebuggingManImage():
+    stream = cStringIO.StringIO(getDebuggingManData())
+    return ImageFromStream(stream)
+
+def getDebuggingManIcon():
+    icon = EmptyIcon()
+    icon.CopyFromBitmap(getDebuggingManBitmap())
+    return icon
+
+#----------------------------------------------------------------------
+