from myro import * myCanvas = GraphWin("My Picture", 200, 100) # myCanvas is global since it is declared outside of the scope of any method. def createLine(x1,y1,x2,y2,outlineColor,pixelWidth): """ This function creates lines. """ L = Line(Point(x1,y1), Point(x2,y2)) L.setOutline(outlineColor) L.setWidth(pixelWidth) L.draw(myCanvas) def createRectangle(x1,y1,x2,y2,outlineColor,pixelWidth): """ This function creates rectangles. """ R = Rectangle(Point(x1,y1), Point(x2,y2)) R.setOutline(outlineColor) R.setWidth(pixelWidth) R.draw(myCanvas) def createCircle(x1,y1,radius,outlineColor,pixelWidth): """ This function creates rectangles. """ C = Circle(Point(x1,y1), radius) C.setOutline(outlineColor) C.setWidth(pixelWidth) C.draw(myCanvas) def main(): myCanvas.setBackground("yellow") y=100 for x in range(50,200,5): createCircle(x,y,25,"black",1) y = y - 2 for x in range(200,350,5): createCircle(x,y,25,"black",1) y = y + 2 createCircle(175,150,22,"magenta",2) createCircle(225,150,22,"magenta",2) main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question