working on a web tutorial. In the first line of the script from the tutorial, there is an import of CoreGraphics. The script it is supposed to draw a yellow rectangle with a red border. My problem is that when i go to run the file by typing:
i get the following error from terminal:
i searched for CoreGraphics with spotlight and i found two folders that matched CoreGraphics. One was located in:
there is another folder located in:
here is the script which i called example1.py. According to the tutorial,
example1.py is taken from, /Developer/Examples/Quartz/Python/ from a script called bitmap.py.
the script example1.py which i took from bitmap.py is a little different than the tutorials. Just wondering about what i would do to make this script work.
Code:
python example1.py
Code:
james-collinss-macbook-pro:python jamescollins$ python example1.py
Traceback (most recent call last):
File "example1.py", line 1, in <module>
from CoreGraphics import *
ImportError: No module named CoreGraphics
Code:
/Developer/SDKs/MacOS10.4u.sdk/Developer/Headers/CFMCarbon
Code:
/Developer/SDKs/MacOS10.5.sdk/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks
example1.py is taken from, /Developer/Examples/Quartz/Python/ from a script called bitmap.py.
Code:
from CoreGraphics import *
import math
# Create an RGB bitmap context, transparent black background, 256x256
cs = CGColorSpaceCreateDeviceRGB ()
c = CGBitmapContextCreateWithColor (256, 256, cs, (0,0,0,0))
# Draw a yellow square with a red outline in the center
c.saveGState ()
c.setRGBStrokeColor (1,0,0,1) # red
c.setRGBFillColor (1,1,0,1) # yellow
c.setLineWidth (3)
c.setLineJoin (kCGLineJoinBevel)
c.addRect (CGRectMake (32.5, 32.5, 191, 191))
c.drawPath (kCGPathFillStroke);
c.restoreGState ()
# Write the bitmap to disk in PNG format
c.writeToFile ("out.png", kCGImageFormatPNG)
the script example1.py which i took from bitmap.py is a little different than the tutorials. Just wondering about what i would do to make this script work.