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 -
from graphics import *
-
-
def main():
-
colour = raw_input("Enter the colour: ")
-
-
def drawCircle(win, centre, radius, colour, color):
-
circle = Circle(centre, radius)
-
circle.setFill(colour)
-
circle.setOutline(color)
-
circle.draw(win)
-
-
def drawWindow(win, center, radius):
-
drawCircle(win, center, radius, "white", "black")
-
-
-
def draw(rows, columns):
-
radius = 50
-
diameter = 2 * radius
-
width = rows*diameter+1
-
height = columns*diameter+1
-
win = GraphWin("", width, height )
-
for x in range( rows ):
-
for y in range( columns ):
-
xPosition = radius + 2 + diameter * x
-
yPosition = radius + 2 + diameter * y
-
center = Point( xPosition, yPosition )
-
drawWindow( win, center, radius )
-
-
-
main()
-
-
2 1179
I have managed to dorrect the first problem by changing the loop around.. but If someone could help me with the second one please..
Hi. Basically you want to pass the colour across as an argument. Something like this: - from graphics import *
-
-
def main():
-
colour = raw_input("Enter the colour: ")
-
draw(4,4,colour) #NOTE CHANGE
-
-
def drawCircle(win, centre, radius, colour, color):
-
circle = Circle(centre, radius)
-
circle.setFill(colour)
-
circle.setOutline(color)
-
circle.draw(win)
-
-
def drawWindow(win, center, radius, mycolour): #NOTE CHANGE
-
drawCircle(win, center, radius, mycolour, "black") #NOTE CHANGE
-
-
-
def draw(rows, columns,mycolour): #NOTE CHANGE
-
radius = 50
-
diameter = 2 * radius
-
width = rows*diameter+1
-
height = columns*diameter+1
-
win = GraphWin("", width, height )
-
for x in range( rows ):
-
for y in range( columns ):
-
xPosition = radius + 2 + diameter * x
-
yPosition = radius + 2 + diameter * y
-
center = Point( xPosition, yPosition )
-
drawWindow( win, center, radius,mycolour ) #NOTE CHANGE
-
-
-
main()
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
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...
|
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...
|
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"),
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |