[wingide-users] Debug - exception - fix - stop - select file - debug: is there an easier way?

Wing IDE Support support at wingware.com
Wed Mar 30 18:49:59 EST 2005

On Thu, 31 Mar 2005, Rene Pijlman wrote:
> I find myself repeating this sequence over and over again:
> 1. My file a.py is current. I hit "Debug".
> 2. An exception occurs in b.py. Wing raises b.py to the front.
>    That's good.
> 3. I fix my bug in b.py.
> 4. I hit "Stop".
> 5. I select a.py
> 6. I hit Debug.
> Is there a way to combine steps 4-6 in one easy keystroke?

Sure, add the following script into a file in the 'scripts'
directory in your User Settings Directory (see 5th item in About
box from Help menu; location varies by OS):

import wingapi
def debug_restart():
  app = wingapi.gApplication

Then change /path/to/a.py to the correct desired main entry point
and select "Reload All Scripts" from the Edit menu (only needed
the first time a new script file is added; after that Wing auto
reloads the files when they are edited and saved from Wing).

Then define a key binding for it using the User Interface /
Keyboard / Custom Key Bindings preference.

This could be made more general by reading the main entry point
out of the project, when it is set, but the API doesn't have a
way to do that right now.  If you want to do that, you can use
the following, which gets just slightly into undocumented API:

import wingapi

def _get_mainfile():
  # Hack to work around missing API
  app = wingapi.gApplication
  mainfile = app.GetAttribute('proj.main-file')
  if mainfile is None:
    return None
    return mainfile.fName
def debug_restart():
  app = wingapi.gApplication
  mainfile = _get_mainfile()
  if mainfile is not None:

This of course requires that you set a main debug file from
from the Debug menu or Project's context menu.

Please let me know if you have any questions.

- Stephan

More information about the wingide-users mailing list