graphics.py circle loop?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cid11
    New Member
    • Jun 2010
    • 10

    graphics.py circle loop?

    how could I loop this to repeat the circles with one circle filled with red colour and one without?

    from graphics import *

    Code:
     
    w = 300
    h = 300
    win = GraphWin("Red Circle", w, h)
    
    
    center = Point(150, 150)
    radius = 80
    circle = Circle(center, radius)
    circle.setFill('red')
    circle.setWidth(2)
    circle.draw(win)
    
    
    win.getMouse()
    win.close()
  • Glenton
    Recognized Expert Contributor
    • Nov 2008
    • 391

    #2
    You could add a loop. Something like this:

    Code:
    red=True
    for i in range(whatever):
        red=not red
        if red:
            #draw your red circle based on i
        else:
            #draw the not red circle (also based on i)

    Comment

    • cid11
      New Member
      • Jun 2010
      • 10

      #3
      I want 25 circles.. so would the range be

      for i in range(25):

      but how could I execute the function for it being filled with red or not? I mean the if and else function?

      Comment

      • Glenton
        Recognized Expert Contributor
        • Nov 2008
        • 391

        #4
        I'm not terribly familiar with the module you're using, but doesn't
        Code:
        circle.setFill('red')
        do it?

        Comment

        Working...