#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: penglaixy
#
# Created: 27/07/2013
# Copyright: (c) penglaixy 2013
# Licence: <your licence>
#-------------------------------------------------------------------------------
import turtle
__import__("turtle").__tracealbe__=False
import time
__import__("time").__tracealbe__=False
def main():
def make_window(colr, ttle):
'''
set up the window with the given background color and title
'''
w = turtle.Screen()
w.bgcolor(colr)
w.title(ttle)
return w
def make_turtle(colr, sz):
'''
set up a turtle with the given color and pensize
'''
t = turtle.Turtle()
t.color(colr)
t.pensize(sz)
return t
def draw_star(t, sz):
''' Make turtle t draw a square of sz'''
for i in range(5):
t.forward(sz)
t.right(144)
def draw_poly(t,n,sz):
'''
draw poly
'''
angel = 360//n
for i in range(n):
t.forward(sz)
t.left(angel)
def choose_pen_color(t, height):
if height >= 200:
t.color("navy blue", "red")
elif height >= 100:
t.color("navy blue", "yellow")
else:
t.color("navy blue", "green")
def draw_bar(t,height):
choose_pen_color(t,height)
t.begin_fill()
t.left(90)
t.forward(height)
if height > 0:
t.write(' '+str(height))
else:
t.penup()
t.forward(-15)
t.write(' '+str(height))
t.forward(15)
t.pendown()
t.right(90)
t.forward(40)
t.right(90)
t.forward(height)
t.end_fill()
t.left(90)
t.penup()
t.forward(10)
t.pendown()
def adjust_window(t):
t.penup()
t.forward(-300)
#t.right(90)
#t.forward(200)
#t.left(90)
t.pendown()
def get_grade(score):
if score >= 75:
print "First"
elif score >= 70:
print "Upper Second"
elif score >= 60:
print "Second"
elif score >= 50:
print "Third"
elif score >= 45:
print "F1 Supp"
elif score >= 40:
print "F2"
else:
print "F3"
#xs = [83, 75, 74.9, 70, 69.9, 65, 60, 59.9, 55, 50,
#49.9, 45, 44.9, 40, 39.9, 2, 0]
#for val in xs:
#print "The score is %f" % val,
#get_grade(val)
wn = make_window('lightgreen','''yuxiangyang's testing''')
alex = make_turtle('navy blue', 5)
adjust_window(alex)
xs = [48, 117, -200, 240, -160, 260,220]
for v in xs:
draw_bar(alex,v)
time.sleep(4)
wn.bye()
if __name__ == '__main__':
main()