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.
- Download the examples from the mcculw GitHub page at github.com/mccdaq.
- 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.
- 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.
- Open an Eclipse workspace; close the Welcome page if it opens.
- Install the PyDev plugin if it is not already installed:
- Go to Help»Install New Software; the Install dialog box opens.
- Click Add, and enter http://pydev.org/updates.
- Select all of the items listed, and follow the prompts to install.
- 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}}
- Enter a name for the new project, such as mcculw examples in the Project name texbox.
- 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.
- If you haven't done so already, configure the interpreter by clicking the link provided.
- Select PyDev»Interpreter»Python Interpreter.
- Click New.
- Enter a name for this interpreter, such as Python.
- Browse to the python executable (python.exe) installed on your system, and click OK. The necessary files are added to the path.
- Apply the changes.
- 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.
- In the PyDev Package Explorer, expand either examples\console or examples\ui folder.
- Right click on the example you wish to run, hover over Debug As and select Python Run.
- 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.
- Open Visual Studio, and select File»New»Project.
The New Project dialog box opens.
- Select Python.
- Select From Existing Python code.
- Enter a name for the project, such as mcculw examples.
- 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.
- Click Finish to complete the wizard.
- 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.
- From the Solution Explorer, expand either the examples\console or examples\ui folder.
- Right click on the example you wish to run and choose Set as Startup File.
- Run the selected example by pressing the Start button on the standard toolbar, or the F5 key on the keyboard.