Hello, im really stuck at the minute. im trying to create a pattern (that is shown below) and this is all that I can get. im not very good with python, but im trying. any help would be appreciated. the actual size of the whole thing has to be 100x100

thank you

import graphics
 
def drawCircle(win, centre, radius, colour):
    circle = graphics.Circle(centre, radius)
    circle.setFill(colour)
    circle.setWidth(2)
    circle.draw(win)
 
def drawCircles(win,x,y):
    centre = graphics.Point(x,y)
    drawCircle(win, centre, 10, "white")
     
def CircleLoop(columns,rows):
    win = graphics.GraphWin("", 100 * columns, 100 * rows)
    for i in range(columns):
        for j in range(rows):
            drawCircles(win,i*100+50,j*100+50)
 
CircleLoop(9,9)

This is the last time I am explaining technique. Start out with something specific that works and expand to the general. Take this code which shows one specific set of 3, and then a second set, and expand so it will print one entire row, then expand so it will print all of the rows.

import graphics
 
def draw_circle(win, x, y, radius, colour):
    centre = graphics.Point(x,y)
    circle = graphics.Circle(centre, radius)
    circle.setFill(colour)
    circle.setWidth(2)
    circle.draw(win)
 
width = 100
height = 100
win = graphics.GraphWin("Circles", width, height)
radius = width/20     ## 10 circles with radius = 1/2 diameter
x = radius            ## up against the corner
y = radius

red = 0
for j in range(3):
    color = "white"
    if red == j:
        color = "red"
    draw_circle(win, x, y, radius, color)
    ## x moves radius X2 
    x += radius+radius

red += 1
x += radius*2
for j in range(3):
    color = "white"
    if red == j:
        color = "red"
    draw_circle(win, x, y, radius, color)
    ## x moves radius X2 
    x += radius+radius

raw_input("")

i am going to install this graphics module now. ;)

It is also available with documentation here. Just copy it to /python/site-packages. I also changed the name of the file to graphicsZ.py because I didn't know it there would be name collusion with the wx graphics.py file.

I keep graphics.py in my debug directory, I do not mind that it is visible in that one directory. I just save code using that module to exclusively that directory. I never use it for my own code anyway.

i've done the first row but how do i get it so that the circles go directly underneath the previous circles

like this

000 000 000
000 000 000
000 000 000

thank you

I just install the girl(graphics). I just found out that the frame and image quality is not as smooth as wxpython.

But its a cool module to play with ;)

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.