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:
                Colours.append(colour)
        else:
                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)
    patch1.draw(win)
    for i in range(10):
        radius = radius - 5
        y = y + 5
        centre = Point(50,y)
        patch1 = Circle(centre, radius)
        #patch1.setFill(colour)
        patch1.draw(win)

main()

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

radius-=5

Line 53 can be

y+=5

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):
        #patch1.setFill(colour)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.