Ask Your Question

Running a function from command line

asked 2022-11-08 04:12:11 -0500

steve1964's avatar

I would like to open the IDE, load a project and start execution from a specified function of the project, everything from the command line. I'm able to invoke wing-personal passing the .wpr and this works fine, my project is loaded and ready to start. How can I automatically start execution (calling a selected function) from the same command line launching the IDE? I would need to execute in debug mode but also in non-debug mode.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-11-08 08:12:58 -0500

There's no support for that level of control from the command line. However, you could write an extension script to do this. It could look at sys.argv and act accordingly. For example, if you add an arg at launch time like say 'wing9 --debug-file=/path/to/my/' it will ignore the unknown arg but you can still see it with sys.argv in your script. Something like this:

import sys
import os
import wingapi

def _custom_launch_args():
  app = wingapi.gApplication

  # Prevent re-processing args if scripts are later reloaded
  if getattr(wingapi, '_processed_args', False):
  wingapi._processed_args = True

  def find_filename(ftype):
    for arg in sys.argv:
      if arg.startswith(ftype):
        filename = arg[len(ftype):]
        if os.path.exists(filename):
          return filename
    return None

  filename = find_filename('--debug-file=')
  if filename is not None:

  filename = find_filename('--execute-file=')
  if filename is not None:


You can try this by dropping it into the 'scripts' directory below the Settings Directory reported in Wing's About box, then quit Wing and try launching with --debug-file= or --execute-file= arg. You may want to test with os.path.isabs(filename) and use os.path.abspath(filename) if not. Other than that I think the above should work.

See for details on scripting/extending the IDE.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2022-11-08 04:12:11 -0500

Seen: 41 times

Last updated: Nov 14 '22