Squiggle

Back to index

Get the following sample program up and running. Study it carefully and maybe do a few experiments with it in order to understand how the create_arc method works.
#!/usr/bin/python from Tkinter import * master = Tk() w = Canvas(master, width=320, height=100, bg="black") w.pack() for x in range(20,300,40): w.create_arc(x,30,x+20,70,start=0,extent=180,outline="green", width=5, style=ARC) w.create_arc(x+20,30,x+40,70,start=180,extent=180,outline="magenta",width=5, style=ARC) mainloop()
There is a lot that can be done with the create_arc method. The first two inputs in the sample program represent the upper-left corner of the bounding rectangle containing the arc. The next two items represent the lower-right corner of the bounding rectangle. The start and extent attributes designate the portion of the arc to be rendered. (Experiment with different values to get a feel for how this works.) The outline and width attributes are simple enough, but the style attribute can take three values. Only the ARC value will be relevant to this lesson. The other two values will be dealt with in the next lesson.
ASSIGNMENT:

Your job will be to revise the sample program so that the squiggly wave thing is oriented vertically instead of horizontally. Also it will be twice as long. Make your canvas 640 units tall and 100 units wide in order to accommodate this alteration.