473,385 Members | 2,269 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,385 software developers and data experts.

Circles help please

10
atlast I have managed to get some working code but the first problem is that I have is taht.. when I call draw(2,4) I have a column of 2 circles and 4 rows and I would actually like it to be a clomun of 2 and row of 4. Secodly although my code works I have a main function and an input for an colour how could I fill the circles with the requested colour?

like
This is what i currently have
00
00
00
00

I want it like

0000
0000

Expand|Select|Wrap|Line Numbers
  1. from graphics import *
  2.  
  3. def main():
  4.     colour = raw_input("Enter the colour: ")
  5.  
  6. def drawCircle(win, centre, radius, colour, color):
  7.     circle = Circle(centre, radius)
  8.     circle.setFill(colour)
  9.     circle.setOutline(color)
  10.     circle.draw(win)
  11.  
  12. def drawWindow(win, center, radius):
  13.     drawCircle(win, center, radius, "white", "black")
  14.  
  15.  
  16. def draw(rows, columns):
  17.       radius = 50
  18.       diameter = 2 * radius
  19.       width = rows*diameter+1
  20.       height = columns*diameter+1
  21.       win = GraphWin("", width, height )
  22.       for x in range( rows ):
  23.          for y in range( columns ):
  24.             xPosition = radius + 2 + diameter * x
  25.             yPosition = radius + 2 + diameter * y
  26.             center = Point( xPosition, yPosition )
  27.             drawWindow( win, center, radius )
  28.  
  29.  
  30. main()
  31.  
  32.  
Jun 25 '10 #1
2 1179
cid11
10
I have managed to dorrect the first problem by changing the loop around.. but If someone could help me with the second one please..
Jun 27 '10 #2
Glenton
391 Expert 256MB
Hi. Basically you want to pass the colour across as an argument. Something like this:

Expand|Select|Wrap|Line Numbers
  1. from graphics import *
  2.  
  3. def main():
  4.     colour = raw_input("Enter the colour: ")
  5.     draw(4,4,colour)    #NOTE CHANGE
  6.  
  7. def drawCircle(win, centre, radius, colour, color):
  8.     circle = Circle(centre, radius)
  9.     circle.setFill(colour)
  10.     circle.setOutline(color)
  11.     circle.draw(win)
  12.  
  13. def drawWindow(win, center, radius, mycolour):  #NOTE CHANGE
  14.     drawCircle(win, center, radius, mycolour, "black")  #NOTE CHANGE
  15.  
  16.  
  17. def draw(rows, columns,mycolour):  #NOTE CHANGE
  18.       radius = 50
  19.       diameter = 2 * radius
  20.       width = rows*diameter+1
  21.       height = columns*diameter+1
  22.       win = GraphWin("", width, height )
  23.       for x in range( rows ):
  24.          for y in range( columns ):
  25.             xPosition = radius + 2 + diameter * x
  26.             yPosition = radius + 2 + diameter * y
  27.             center = Point( xPosition, yPosition )
  28.             drawWindow( win, center, radius,mycolour )  #NOTE CHANGE
  29.  
  30.  
  31. main()
Jul 7 '10 #3

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...
0
by: Heinrich Braasch | last post by:
Thanks in advance. When running from a remote machine, I was quite able to server-side create COM connections to WORD and OUTLOOK while using the VB Studio.Net 2002 version using the following...
0
by: Ranjit | last post by:
Hi, I would like to know how to place circles in the connecting points of the lines, and very close to the circles I would like to place the values like a,b,c...etc automatically for each...
0
by: dgk | last post by:
A friend wants to have two circles containing letters. One would be stationary and the other would rotate around the first one. I know how to get the graphic form thingie from the Form Paint event...
5
by: Laurent Allardin | last post by:
Hi, Why this code compile??? We should not be able to Override the code by using the Overloads since the sub as exactly the same parameters.... Thank you. Laurent Allardin,MCSD,MCAD
0
by: Gilgamesh | last post by:
Hi, I have some very limited knowledge of web development but I have an imagemap in which I want to be able to display a small yellow circle at certain pre-define locations. When the user moves...
3
by: Douglas Douglas | last post by:
Hi everybody. I have a paper form that I scan into an image. My user fills some circles in this paper form using black ink. Every form has ten rows with five circles each and the user fills only...
4
by: jason.m.ho | last post by:
Hello, I am writing a no-plugin networked Sketchpad program (DHTML, Comet/Ajax). Because I am trying to avoid using Flash or Java Applet, I rendered my strokes at first with the wz_jsgraphics...
15
zorgi
by: zorgi | last post by:
Hi Guys I have this algorithm problem to share with you: :) Imagine you have two dimensional array like this: $my_array = array( "b" => array("t", "p"), "t" => array("p", "b"),
2
by: pranava | last post by:
I was writing a program to read the command line Integer Argument and Perform some simple operations such addition,Multiplication etc., The following is its code import java.lang.Math; class...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.