Template:PT3 PYTHON WIN IDLE: Difference between revisions

From Phidgets Support
(Created page with "<div class="phd-slide-deck" data-deck="PT3_PYTHON_WIN_IDLE"> <div class="phd-slide-deck-header"><h3>Language - Python</h3></div> <div class="phd-slides"> <div class="phd-slide...")
 
No edit summary
 
Line 22: Line 22:


<div class="phd-slide">
<div class="phd-slide">
<h2>Requirements</h2>
<h2>Installing the Phidget Python Module</h2>


<p>First, make sure you have the following installed:</p>
<p>First, install <span>[https://www.python.org/downloads/ Python3]</span> if you haven't already.</p>
 
<p>● Phidgets Drivers for Windows (see Part 1 of this user guide)</p>
 
<p>● <span>[https://www.python.org/downloads/ Python]</span> (2.7 and 3.6+ are both compatible with Phidgets)</p>
</div>
 
<div class="phd-slide">
<h2>Installing the Phidget Python Module</h2>


<p>
<p>
Python versions 2.7.9+ and 3.4+ include PIP by default. To install the Phidget22 Python module with PIP, simply open the <b>Command Prompt</b> (press the
Python 3.4+ includes PIP by default. To install the Phidget22 Python module with PIP, simply open the <b>Command Prompt</b> (press the Windows key and search
Windows key and search for <b>cmd</b>), and enter the command:
for <b>cmd</b>), and enter the command:
</p>
</p>


<div class="phd-command-line"><code>python -m pip install Phidget22</code></div>
<div class="phd-command-line"><code>python -m pip install Phidget22</code></div>
<p>
To install the Phidget22 libraries to a specific Python version, you can use the <b>Python Windows Launcher</b> from the Command Prompt as follows (replace
<b>-X.X</b> with your Python version, e.g. -2.7 or -3.6):
</p>
<div class="phd-command-line"><code>py -X.X -m pip install Phidget22</code></div>
<p>If you don't use PIP, follow the manual installation instructions on the next slide.</p>
</div>
<div class="phd-slide">
<h2>Installing the Phidget Python Module</h2>
<p>To install the Phidget22 Python module without PIP, you need to download it here:</p>
<p>● <span>[https://www.phidgets.com/downloads/phidget22/libraries/any/Phidget22Python.zip Phidget22 Python Module]</span></p>
<p>
Unpack the Phidget22 Python module and open the Command Prompt (press the Windows key and search for <b>cmd</b>). Find the folder where you downloaded the
Python module and enter this command:
</p>
<div class="phd-command-line"><code>python setup.py install</code></div>
<p>This will build the module and install the Python module files into your site-packages directory.</p>
<div class="phd-lazy-image" data-src="https://www.phidgets.com/decks/PT3_PYTHON_WIN_IDLE/-x180/50/Python_install.png"></div>
</div>
</div>



Latest revision as of 22:14, 17 December 2024

Windows with IDLE

Welcome to using Phidgets with Python! By using Python, you will have access to the complete Phidget22 API, including events.

IDLE is a cross-platform development environment for Python targeted at newcomers to the language.

WARNING: We do not recommend using Idle with Phidgets. It has known problems dealing with multiple threads, which is a required feature if your program uses events.

Installing the Phidget Python Module

First, install Python3 if you haven't already.

Python 3.4+ includes PIP by default. To install the Phidget22 Python module with PIP, simply open the Command Prompt (press the Windows key and search for cmd), and enter the command:

python -m pip install Phidget22

Finding Code Samples

To find the code sample to use for your Phidget, navigate to the Code Samples page and select your device from the drop-down menu.

Once you select your device, the code sample generator will give you a working code sample, and a selection of options to customize it to your needs.

Using the Code Samples

If it's unclear what any of the options do, click on the nearby '?' for more info.

Once you've made your selections, click the copy button.

Using the Code Samples

Paste the sample code into a new Python script file in IDLE:

Using the Code Samples

To run the example, simply click on Run and select Run Module:

What's Next?

Now that you've set up Phidgets in your programming environment, you should read our guide on Phidget Programming Basics to learn the fundamentals of programming with Phidgets.

«
»