Hi i am trying to create a function that asks the user to enter height and width then colour to then display each pattern in the selected colours.

i made a start but i cant make it work with the colour nor adding size dimensions.

# mini_project.py
from graphics import*

def main():
    height = getHeight()
    width = getWidth()
    Colours = Colours()
    drawPatchwork(height, width, Colours)
    drawPatchOne(win, 5, 5, colour)
    drawPatchTwo(win, 5, 5, colour)

def getHeight():
    patchDimensions = range(3,8)
    height = 0
    while height not in patchDimensions:
        print "Please enter the patch height vaule: "
        height = input ("Enter height dimension: ")
        if height not in patchDimensions:
            print "Re-enter as an integer. "
    return height

def getWidth():
    patchDimensions = range(3,8)
    width = 0
    while width not in patchDimensions:
        print "Please enter the patch width vaule: "
        width = input ("Enter width dimension: ")
        if width not in patchDimensions:
            print "Re-enter vaule as an integer. "
    return width

def Colours():
    Colours = []
    while len(Colours)< 3:
        print "Please pick a colour vaule"
        colour = raw_input("Colour?")
        if colours not in Colour:
                print "Colour already has been choosen. "
                print "Make another choice."
        return Colours
def drawPatchOne(win, Colours, y):
    y = 51
    centre = Point(51.47,y)
    radius = 50
    patch1 = Circle(centre, radius)
    for i in range(10):
        radius = radius - 5
        y = y + 5
        centre = Point(50,y)
        patch1 = Circle(centre, radius)

6 Years
Discussion Span
Last Post by woooee

For a start, on line 9 you call:

drawPatchwork(height, width, Colours)

You don't have a function called "drawPatchwork"

In line 45, you pass a value to variable "y" in the variables. However, you then instantly overwrite it in the next line to value "51".

Line 52 can be


Line 53 can be


Edited by SgtMe: n/a


i made a start but i cant make it work with the colour nor adding size dimensions.

That is a little vague. Post one function with a description of what you want it to do. Also in getWidth() and getHeight() it will error out in Python 2.X if a non-digit is entered (what version of Python are you using?). You should catch errors or use raw_input and test the string using isdigit() before converting to an int. And both of these functions, getWidth and getHeight, are the same except for the literal printed. You can use one function and pass "width" or "height" to it. Finally, note the difference in the variable names here

def drawPatchOne(win, Colours, y):

Edited by woooee: n/a

This question has already been answered. 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.