| 1 |
Running Pygame Zero in IDLE and other IDEs |
| 2 |
========================================== |
| 3 |
|
| 4 |
.. versionadded:: 1.2 |
| 5 |
|
| 6 |
Pygame Zero is usually run using a command such as:: |
| 7 |
|
| 8 |
pgzrun my_program.py |
| 9 |
|
| 10 |
Certain programs, such as integrated development environments like IDLE and |
| 11 |
Edublocks, will only run ``python``, not ``pgzrun``. |
| 12 |
|
| 13 |
Pygame Zero includes a way of writing a full Python program that can be run |
| 14 |
using ``python``. To do it, put :: |
| 15 |
|
| 16 |
import pgzrun |
| 17 |
|
| 18 |
as the very first line of the Pygame Zero program, and put :: |
| 19 |
|
| 20 |
pgzrun.go() |
| 21 |
|
| 22 |
as the very last line. |
| 23 |
|
| 24 |
|
| 25 |
Example |
| 26 |
------- |
| 27 |
|
| 28 |
Here is a Pygame Zero program that draws a circle. You can run this by pasting |
| 29 |
it into IDLE:: |
| 30 |
|
| 31 |
|
| 32 |
import pgzrun |
| 33 |
|
| 34 |
|
| 35 |
WIDTH = 800 |
| 36 |
HEIGHT = 600 |
| 37 |
|
| 38 |
def draw(): |
| 39 |
screen.clear() |
| 40 |
screen.draw.circle((400, 300), 30, 'white') |
| 41 |
|
| 42 |
|
| 43 |
pgzrun.go() |
| 44 |
|