Oval Time

Back to index

There is a time for rectangles and a time for polygons, but in this lesson it's time for ovals! You might also notice that "oval time" sounds a little like Ovaltine, but don't expect a cup of sweet, flavored milk. In any case, here's the sample script for you to get up and running.
#!/usr/bin/python from tkinter import * master = Tk() w = Canvas(master, width=200, height=200) w.pack() w.create_rectangle(0,0,200,200,fill="yellow") for x in range(0,10): for y in range(0,10): w.create_oval(13+18*x,14+19*y,23+18*x,20+19*y,fill="green") #w.create_oval(20,60,180,140,fill="red") w.create_oval(15,55,185,145,outline="blue",width=3) w.create_oval(55,15,145,185,outline="blue",width=3) mainloop()
The main focus of this lesson is the create_oval function. As you can see it takes a list of coordinates and then some optional items such as outline, fill, and width. Other optional items include dash, tags, stipple, and offset. BTW, the list of coordinates could be supplied in this fashion:
corners_of_oval=(15,55,185,145) w.create_oval(corners_of_oval,outline="blue",width=3)

ASSIGNMENT:

Create a pattern matching the following specifications:

  1. Create nine columns of ovals
  2. The ovals in the odd-numbered columns will be filled green with their long axis situated vertically
  3. The ovals in the even-numbered columns will be filled blue with their long axis situated horizontally
  4. Space the columns evenly and make the background color light orange
  5. In the center of your canvas and on top of the background of smaller ovals draw a set of five embedded ovals
  6. The embedded ovals will not be filled and their outline color will be black