Importing Python for Windows Example Programs Into an IDE

Python for Windows example programs can be imported into any IDE that supports Python, such as Eclipse (Neon and later) or Visual Studio (2015 and later). Before performing the following steps, install the MCC UL Python API for Windows.

  1. Download the examples from the mcculw GitHub page at github.com/mccdaq.
  2. Create a new folder and unzip the examples to the folder location. For this example, the programs are unzipped to C:\Users\Public\Documents\Measurement Computing\DAQ\Python.
  3. Perform the following procedures to import the example programs into Eclipse or Visual Studio.

Importing the Python for Windows example programs into Eclipse with PyDev Eclipse Neon.3 – Eclipse IDE for Java Developers required. Other versions of Eclipse will be similar. These instructions assume you have already installed Eclipse.

  1. Open an Eclipse workspace; close the Welcome page if it opens.
  2. Install the PyDev plugin if it is not already installed:
    1. Go to Help»Install New Software; the Install dialog box opens.
    2. Click Add, and enter http://pydev.org/updates.
    3. Select all of the items listed, and follow the prompts to install.
  3. Right click in the Package Explorer, and go to New»Project.

The New Project dialog box opens.

  {{https://files.digilent.com/reference-images/eclipse-newproj.png?525x521}}
- 	Open the PyDev folder, select PyDev Project, and click Next.   
  
  {{https://files.digilent.com/reference-images/eclipse-pydevproj.png?547x747}}
  1. Enter a name for the new project, such as mcculw examples in the Project name texbox.
  2. Under the Project contents area, uncheck Use default and specify the directory where the examples were unzipped, typically C:\Users\Public\Documents\Measurement Computing\DAQ\Python. This path must be exact, since a Python namespace is directly tied to the directory structure.
  3. If you haven't done so already, configure the interpreter by clicking the link provided.
    1. Select PyDev»Interpreter»Python Interpreter.
    2. Click New.
    3. Enter a name for this interpreter, such as Python.
    4. Browse to the python executable (python.exe) installed on your system, and click OK. The necessary files are added to the path.
    5. Apply the changes.
  4. Click Finish to complete the process.

Running the examples Follow the procedure below to run console-based examples or user interfaced-based Python for Windows example programs.

  1. In the PyDev Package Explorer, expand either examples\console or examples\ui folder.
  2. Right click on the example you wish to run, hover over Debug As and select Python Run.
  3. After running the example once, subsequent runs may be performed by clicking on the Debug button on the toolbar, or by pressing the F11 key on the keyboard.

Importing the Python for Windows example programs into Visual Studio with Python Tools for Visual Studio (PTVS) The following instructions are intended for Visual Studio 2017. Other versions of Visual Studio should be similar. These instructions assume you have already installed Visual Studio 2017 with the PTVS.

  1. Open Visual Studio, and select File»New»Project.

The New Project dialog box opens.

  1. Select Python.
  2. Select From Existing Python code.
  3. Enter a name for the project, such as mcculw examples.
  4. In the Location text box, enter the directory where the examples were unzipped, typically C:\Users\Public\Documents\Measurement Computing\DAQ\Python, and click OK. This path must be exact, since Python namespaces are directly tied to the directory structure.

The Create New Project from Existing Python Code Wizard dialog box opens.

  1. Click Finish to complete the wizard.
  2. In the Solution Explorer, right click on Search Paths, select …, add the directory where the Python examples were unzipped (typically C:\Users\Public\Documents\Measurement Computing\DAQ\Python), and click Select Folder.

Running the examples User-interface-based examples and console-based examples are installed. Perform the rollowing procedure to run an examply program.

  1. From the Solution Explorer, expand either the examples\console or examples\ui folder.
  2. Right click on the example you wish to run and choose Set as Startup File.
  3. Run the selected example by pressing the Start button on the standard toolbar, or the F5 key on the keyboard.