473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

graphics.py circle loop?

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

from graphics import *

Expand|Select|Wrap|Line Numbers
  1.  
  2. w = 300
  3. h = 300
  4. win = GraphWin("Red Circle", w, h)
  5.  
  6.  
  7. center = Point(150, 150)
  8. radius = 80
  9. circle = Circle(center, radius)
  10. circle.setFill('red')
  11. circle.setWidth(2)
  12. circle.draw(win)
  13.  
  14.  
  15. win.getMouse()
  16. win.close()
  17.  
Jun 17 '10 #1
3 3873
Glenton
391 Expert 256MB
You could add a loop. Something like this:

Expand|Select|Wrap|Line Numbers
  1. red=True
  2. for i in range(whatever):
  3.     red=not red
  4.     if red:
  5.         #draw your red circle based on i
  6.     else:
  7.         #draw the not red circle (also based on i) 
  8.  
Jun 18 '10 #2
cid11
10
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?
Jun 18 '10 #3
Glenton
391 Expert 256MB
I'm not terribly familiar with the module you're using, but doesn't
Expand|Select|Wrap|Line Numbers
  1. circle.setFill('red')
do it?
Jun 18 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: ComputerSmith | last post by:
Hi all. I have programmed VB6 apps before, ones that use dropdown listboxes, text boxes, etc... normal stuff. I was asked by a friend to write a "simple" app that I am unsure how to proceed...
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
7
by: Stefan0 | last post by:
Hi, I'd like to draw a circle on the screen using GDI+ I'm using the DrawEllipse method with width = height and I set the SmootingMode to SmoothingModeAntiAlias but the circle is "squared". Is...
4
debasisdas
by: debasisdas | last post by:
This article contains the basic syntax to draw graphics of various shapes and sizes in Visual Basic 6.0. Different types of geometrical shapes (rectangle, square, circle, arc, ellipse etc.) can be...
7
by: Tem | last post by:
I need to draw a black lined circle and save it as a gif file. Can this be done with wpf or do I need to use GDI+ The examples I found seem to only apply to UI elements not a file. Thank you ...
4
by: Slickuser | last post by:
How do I automatic move the X & Y to create a ellipse function as below, DrawCircle? Or there any sample source code out there? I want it move down by user input. How can I achieve this?...
9
by: koschwitz | last post by:
Hi, I hope you guys can help me make this simple application work. I'm trying to create a form displaying 3 circles, which independently change colors 3 times after a random time period has...
8
by: Abhiraj Chauhan | last post by:
I need someone to make an example of how to create a graphics window in VB.net 2008. I understand the basics of how to draw a rectangle and lines etc. What I need is an example of how to make a...
1
by: hdivecha | last post by:
i have make a jtree program in java and if the node is circle then the circle can be shown in frame and i have to resize it with slider . plz help me i have done the tree program bt how to get...
26
by: OzzyB | last post by:
This is another problem in the Zelle book. def drawCircle(win, centre, radius, colour): circle = Circle(radius) circle.setFill(colour) circle.setWidth(2) circle.draw(win) ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.