0

I have this code below where I have to make it a function. I'm confused.
I tried

def drawLine(img): 
....
....
....

Do I set the location of the picture as my variable? and then calling it? How would I call my
parameter when I want to check the code? I'm confused on this..
The code is below.

from cImage import*
import random

def drawLine(img):

    myImWin = ImageWin("Line Image", 300, 300)
    lineImage = EmptyImage(300,300)
    redPixel = Pixel(255,0,0)
    randomRed = Pixel(random.randint(0,255),0,0)
    for i in range(300):
        for x in range(250):
            lineImage.setPixel(50,i,redPixel)
            lineImage.setPixel(150,x,randomRed)
    lineImage.draw(myImWin)
    lineImage.save("lineImage.gif")

    myImWin.exitonClick()
2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by pyTony
0

Oh okay, this is what I thought in the 1st place;
But our lab professor said it takes one parameter.

And I'm getting an error for the last code myImWin.exitonClick()
it says : 'ImageWin' object has no attribute 'exitonClick''
I have no idea why this is happening.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.