Understanding the onecircle.py script
First, let's ake a look a the file:
# Import everything from Graphics
from graphics import *
# Build a window
win = GraphWin('Test 1', 600, 600)
win.setBackground('white')
# Draw one circle
poly = Circle( Point( 300, 300 ), 200 )
poly.setFill( 'red' )
poly.draw(win)
# Add some text
mytext = Text( Point(450, 520), 'by Random Bytes' )
mytext.setFill('red')
mytext.setSize( 30 )
mytext.draw(win)
# Wait to stop
win.getMouse()
win.close()
Step 1 - Import useful code from other files
Python is such a useful language because it is possible to borrow code from other file,to do pretty much anything that you can think about. In this file, we need to tell our script to import all objects and function from the file graphics.py . Without this import statement, it wouldn't not be possible to create a window object (GraphWin), a point (Point), a circle (Circle) and some on-screen text (Text). The import code is made here of a single line:
from graphics import *
