Next / Previous / Contents

8.11. Canvas oval objects

Ovals, mathematically, are ellipses, including circles as a special case. The ellipse is fit into a rectangle defined by the coordinates (x0, y0) of the top left corner and the coordinates (x1, y1) of a point just outside of the bottom right corner.

The oval will coincide with the top and left-hand lines of this box, but will fit just inside the bottom and right-hand sides.

To create an ellipse on a canvas C, use:

    id = C.create_oval(x0, y0, x1, y1, option, ...)

which returns the object ID of the new oval object on canvas C.

Options for ovals:

Table 11. Canvas oval options

activedash These options specify the dash pattern, fill color, outline color, outline stipple pattern, interior stipple pattern, and outline width values to be used when the oval is in the tk.ACTIVE state, that is, when the mouse is over the oval. For option values, see dash, fill, outline, outlinestipple, stipple, and width.
activefill
activeoutline
activeoutlinestipple
activestipple
activewidth
dash To produce a dashed border around the oval, set this option to a dash pattern; see Section 5.13, “Dash patterns”
dashoffset When using the dash option, the dashoffset option is used to change the alignment of the border's dash pattern relative to the oval. See Section 5.14, “Matching stipple patterns”.
disableddash These options specify the appearance of the oval when the item's state is tk.DISABLED.
disabledfill
disabledoutline
disabledoutlinestipple
disabledstipple
disabledwidth
fill The default appearance of an oval's interior is transparent, and a value of fill='' will select this behavior. You can also set this option to any color and the interior of the ellipse will be filled with that color; see Section 5.3, “Colors”.
offset Stipple pattern offset of the interior. See Section 5.14, “Matching stipple patterns”.
outline The color of the border around the outside of the ellipse. Default is outline='black'.
outlineoffset Stipple pattern offset of the border. See Section 5.14, “Matching stipple patterns”.
stipple A bitmap indicating how the interior of the ellipse will be stippled. Default is stipple='', which means a solid color. A typical value would be stipple='gray25'. Has no effect unless the fill has been set to some color. See Section 5.7, “Bitmaps”.
outlinestipple Stipple pattern to be used for the border. For option values, see stipple below.
state By default, oval items are created in state tk.NORMAL. Set this option to tk.DISABLED to make the oval unresponsive to mouse actions. Set it to tk.HIDDEN to make the item invisible.
tags If a single string, the oval is tagged with that string. Use a tuple of strings to tag the oval with multiple tags. See Section 8.4, “Canvas tags”.
width Width of the border around the outside of the ellipse. Default is 1 pixel; see Section 5.1, “Dimensions” for possible values. If you set this to zero, the border will not appear. If you set this to zero and make the fill transparent, you can make the entire oval disappear.