The PythonWin IDE

To write Python programs for your Scribble robot, you will not use JES, but another IDE. IDE means “Integrated Development Environment”. The IDE you will use is PhytonWin (see Figure 1). Do not be scared! PhytonWin is an IDE simpler than JES, but, as in JES, you can write the Python functions, as well asfunctions that your Scribbler understands, as commandsin the Interactive Window. As in JES you can write Python programs and save them in a file; the only difference is that the programs are called Scripts in PhytonWin.

Figure x

Try the following in the Interactive Window:

> print "Hello"

Hello

> a=9

> b=10.0

> print a+b

19.0

Seen? Like in JES!

If you want to create your program, and save it in a file, do the following:

  1. Click the File Menu, and choose New file

This window opens up:

  1. Click OK

The following window opens up:

  1. Write your function(s) in the window above. For example:
  1. And then save it in a file. Just click the File Menu, and the Save As. The following window opens up:

Give a name to your program and click Save

Assume you saved your program above with the name mypgm. Now to execute your function, do the following:

  1. click the File Menuand choose Run. The following window opens up:
  1. click Browse to find you program. The following window opens up

  1. select your program (mypgm), and click Open
  2. then click OK in the Run script window (see 1. Above). This will cause all the functions in the file to be loaded into the memory. You need to call the functions which you want to execute at the end of your file (look at how the main function is executed in the two sample examples example1 and example2 the link to which is present in the assignment web page). After loading all the functions in the memory, the functions which you have called in your file will be executed!

Now, your Scribbler robot understands specific Python functions. For example, there are functions that instruct your robot to move forward, or to turn right or left(insert examples here). Of course, these functions would not make sense if you do not have a robot: think of telling your PC to turn left! Your PC does not have a motor, or wheels!

Well, all these functions are “packaged” in what is called a library. A library has a name (remember, we can give namesto Python variables, to our functions, to our files…). We can do the same for libraries. The library we are going to use is called myro.

But we have to instruct Python that we want to use the functions of the myro library. That’s simple! We just write in PythonWin the following command:

>from myro import *

This command tells Python that we are going to use any of the functions provided by the myro library.

PythonWin will display the following:

> from myro import *

(c) 2006-2007 Institute for Personal Robots in Education

[See for more information]

Myro version 2.8.2 is ready!

After issuing the import, some useful information is printed about Myro and then the Shell is ready for the next Python command. Now it is time to connect to the robot by issuing thefollowing command:

> initialize("comX")

where X is the port number using which your computer is using to communicate with the robot.

Now we are ready! We can enter in PythonWin the functions understood by our Scribble robot!