Skip to content Skip to sidebar Skip to footer

Is It Possible To Fill The Outside Of An Arc/oval In Tkinter Canvas?

I'm experimenting with laying patterns of shapes on tkinter canvas. So far I've been successful in filling a rectangle with patterns (like laying bricks) and it shows up fine: im

Solution 1:

Well, there are a couple different ways to go about this. For an arc, all you need to do is create the rest of the arc, in a color of your choosing. For example, if the arc degree is 134 degrees, we could create an arc of 226 degrees, adding up to the full 360 degrees of a circle/oval.

extent = 134 # How far the arc goes
canvas.create_arc(100, 100, 200, 200, extent = extent) # Create first arc
canvas.create_arc(100, 100, 200, 200, extent = (360 - extent)) 
# Create second arc with same circle

For the border of an oval, you have a couple options. First you could set the canvas background to the color you want, like this:

canvas.create_oval(100, 100, 200, 200, width = 5000, outline = 'red') 
#The width of the border is 5000

Which makes the border so big that it covers the entire screen. If you want to make other objects, make them after you make the initial oval.

You could also just set the background of the canvas to the color you want by using the bg operation:

canvas = Canvas(master, width = 750, height = 500, bg = 'red') 

Post a Comment for "Is It Possible To Fill The Outside Of An Arc/oval In Tkinter Canvas?"