Difference between revisions of "CSC111 Lab 5"

From dftwiki3
Jump to: navigation, search
(Directions for Mac laptops)
Line 1: Line 1:
 
<bluebox>
 
<bluebox>
This lab deals with functions and graphics.
+
This lab deals with functions and graphics. '''Note that you will not be able to run graphics program when connected to beowulf through secure shell (except if you have a Mac).'''  The rule will be that we'll be using Mac OS X to run the graphics program.  There is a section at the end of this lab to explain how to setup your own personal computer for running graphics programs.
 
</bluebox>
 
</bluebox>
  
Line 7: Line 7:
 
<br />
 
<br />
 
<br />
 
<br />
==Installing the Graphics Package on your laptop==
+
==Setup==
 +
This section deals with setting up the graphics environment in you account.
 +
 
 +
==Installing the Graphics Package on your laptop (if you wish)==
  
 
Use these directions if  you would like to have python and the graphics library installed on your own computer.
 
Use these directions if  you would like to have python and the graphics library installed on your own computer.

Revision as of 13:25, 22 February 2010

This lab deals with functions and graphics. Note that you will not be able to run graphics program when connected to beowulf through secure shell (except if you have a Mac). The rule will be that we'll be using Mac OS X to run the graphics program. There is a section at the end of this lab to explain how to setup your own personal computer for running graphics programs.




Setup

This section deals with setting up the graphics environment in you account.

Installing the Graphics Package on your laptop (if you wish)

Use these directions if you would like to have python and the graphics library installed on your own computer.

Directions for Windows laptops

(These directions were inspired by directions posted at the Rose-Hulman Institute of Technology)

Python

First, Install Python 2.6 on your machine, if you haven't already done so.
  • Logon as an adminstrator if you have a regular user account and an administrator account for your laptop (most people use the same for both).
  • Download Python (it's free!). Visit http://www.python.org/download/ and select the Python 2.6.2 Windows installer.
  • Run the installer, installing it in C:\Program Files\Python26\ (vs. the default, which is C:\Python26 ). The other defaults are fine to use.
  • Change the directory that the Python development environment, IDLE, starts in when loading and saving files. (By default it looks for and saves files in the program directory.)
    • Log into your regular user account if it is different from your administrator account.
    • Click on Start → All Programs → Python 2.6
    • Right-click on IDLE (Python GUI) and choose Properties
    • Change the Start in: field to point to the place where you want to keep Python program files. A good choice might be C:\Documents and Settings\yourname\My Documents\PythonFiles. (An easy way to get that path name: Open My Documents and browse to the folder. Select the pathname in the Address bar; Copy. Go back to the Idle Properties Window, and Paste into the Start In field.) Whatever folder you decide to use, you will need to use Windows Explorer to create it if it does not exist.


Then load the Zelle Graphics library
  • Download this file graphics.py.
  • Save the file graphics.py in the directory C:\Program Files\Python26\Lib\site-packages
Potential “gotchas”: (1) That is Lib, not libs, in the path. (2) if you installed Python in a different location than C:\Program Files\Python26, you’ll need to find your Python26\Lib\site-packages folder.
To verify your installation
  • Launch IDLE by clicking Start → All Programs → Python 2.6 → IDLE (Python GUI)
  • At the prompt type:
 from graphics import *

if you do not get an error message, then the installation was successful.

Directions for Mac laptops

  • Use Finder to create a new folder in your favorite spot. For example you can create a folder called CSC111 on your Desktop.
  • Download this file graphics.py, and unzip it. Put grahpics.py in the directory (folder) you created above.
  • Open a terminal window, and type the following commands:
 cd
 cd Desktop
 cd CSC111            (or whatever directory you decided to create)
 emacs testgraphics.py
  • create the following python program:
from graphics import *
def main():
    test()

main()

  • Run it!
  python testgraphics.py
  • You should get this new window on your screen:



GraphicsTest.png