A circle from an arc

Another way to make a circle is to use the create_arc() method. This method may appear to be a more natural way to make circles but it does not allow you to quite complete the circle. If you do try to the circle disappears.

How to do it...

The instructions used in the first example should be used.

Just use the name arc_circle.py when you write, save and execute this program.

# arc_circle.py
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>              
from Tkinter import *
root = Tk()
root.title('Should be a circle')
cw = 210                                      # canvas width
ch = 130                                      # canvas height
canvas_1 = Canvas(root, width=cw, height=ch, background="white")
canvas_1.grid(row=0, column=1)                              

xy = 20, 20, 320, 320         # bounding box from x0,y0 to x1, y1
 # The Arc is drawn  from start_angle, in degrees to finish_angle.
# but if you try to complete the circle at 360 degrees it evaporates.
canvas_1.create_arc(xy, start=0, extent=359.999999999, fill="cyan")
root.mainloop()
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

How it works...

The results are given in the next screenshot, showing a failed circle resulting from create_arc().

How it works...

Generally the create_arc() method is not the best method of making complete circles because an attempt to go from 0 to 360 degrees results in the disappearance of the circle from view. Rather use the create_oval() method. However, there are occasions when you need the properties of the create_arc() method to be able to create a particular distribution of color. See the color wheel in the later chapters for a good example of this.

There's more...

The create_arc() method is well suited to the production of the pie charts favored in corporate presentations. The create_arc() method draws a segment of a circle with the ends of the arc joined to the center by radial lines. But if we just want to draw a circle those radial lines are unwanted.