<type>how-to</type>
<domain>install</domain>
<id>maya</id>
<title>Using Wing with Source Filmmaker</title>
<date>$Date: 2006-05-26 17:43:42 -0400 (Fri, 26 May 2006) $</date>
<product>per+</product>
<summary>Tips for using Wing with Python code running under Source Filmmaker, a movie-making tool built by Valve using the Source game engine.</summary>

.. image:: /images/screenshots/wing7-screenshot-dark.png
  :alt: Wing Screen Shot
  :width: 574
  :height: 423
  :popup: 1

`Wing <https://wingware.com>`__ is a Python IDE that can be used to develop, test, and
debug Python code written for `Source Filmmaker (SFM)
<http://www.sourcefilmmaker.com/>`__, a movie-making tool built by Valve using the Source
game engine. 

Two versions of Wing are appropriate for use with this document: Wing Pro is the
full-featured Python IDE for professional developers, and Wing Personal is a free
alternative with reduced feature set.

If you do not already have Wing installed, `download it now <https://wingware.com/downloads>`__.

This document describes how to configure Wing for Source Filmmaker. To get started using
Wing as your Python IDE, please refer to the tutorial in Wing's ``Help`` menu or read the
`Quickstart Guide <ref:howtos/quickstart>`__.

Debugging Setup
---------------

Wing can debug Python code that's saved in a file, but not code entered in the Script
Editor window. As of version 0.9.8.5 (released May 2014), this includes scripts run from
the main menu. In all versions, code in imported modules may be debugged.

When debugging Python code running under ``SFM``, the debug process is initiated from
outside of Wing, and must connect to the IDE. This is done with ``wingdbstub``, as
described in in the `Debugging Externally Launched Code
<ref:debug/debugging-externally-launched-code>`__ section of the manual. Because of how
``SFM`` sets up the interpreter, you must set ``kEmbedded=1`` in your copy of
``wingdbstub.py``.

Some versions of ``SFM`` comes with ``wingdbstub.py`` in the site-packages directory in
its Python installation. However, this file must match the version of Wing you are using
so you may need to copy ``wingdbstub.py`` from your Wing install directory to the
site-packages directory. The default location of the site-packages directory is::

    <STEAM>\steamapps\common\SourceFilmmaker\game\sdktools\python\2.7\win32\Lib\site-packages

Before debugging, click on the bug icon in lower left of Wing's window and make sure that
``Accept Debug Connections`` is checked. After that, you should be able to reach
breakpoints by causing the scripts to be invoked from ``SFM``.

To start debugging and ensure there's a connection from the ``SFM`` script being debugged
to Wing, execute the following before any other code executes::

    import wingdbstub
    wingdbstub.Ensure()

To use the ``python`` executable found in the ``SFM`` application directory to run Wing's
Python Shell tool and to debug standalone Python scripts, enter the full path of the
python.exe file in the `Python Executable field of the Project Properties dialog
<script:view_project_properties#highlighted_attrib="proj.pyexec">`__.

Related Documents
-----------------

For more information see:

* `Source Filmmaker website <http://www.sourcefilmmaker.com/>`__

* `Quickstart Guide <ref:howtos/quickstart>`__ contains additional basic information
  about getting started with Wing.
  
* `Tutorial <ref:intro/tutorial>`__ provides a gentler introduction to Wing's features.

* `Wing Reference Manual <ref:manual>`__ documents Wing in detail.
