I ran into a problem with rendering an arc on tkinter canvas. (I am using recommended methods for scaling and scrolling the canvas, see my code...)
The code creates an arc on the canvas, its style is 'pieslice'
.
At first everything seems to work OK, but when I keep zooming-in to the curved edge of the shape, at some point it starts to mismatch with the other edges and eventually it disappears...
If I keep zooming even more, other edges disappear as well...
from tkinter import *
root = Tk()
root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)
cnv = Canvas(root)
cnv.grid(row=0, column=0, sticky='nswe')
cnv.create_arc(20, 20, 250, 250, start=0, extent=30)
def scroll_start(event):
cnv.configure(cursor='fleur')
cnv.scan_mark(event.x, event.y)
def scroll_move(event):
cnv.scan_dragto(event.x, event.y, 1)
def scroll_end(event):
cnv.configure(cursor='arrow')
def zoom(event):
if event.delta > 0:
cnv.scale('all', cnv.canvasx(event.x), cnv.canvasy(event.y), 1.1, 1.1)
else:
cnv.scale('all', cnv.canvasx(event.x), cnv.canvasy(event.y), 0.9, 0.9)
cnv.bind('<Button-3>', scroll_start)
cnv.bind('<B3-Motion>', scroll_move)
cnv.bind('<ButtonRelease-3>', scroll_end)
cnv.bind('<MouseWheel>', zoom)
root.mainloop()
Is there a way to fix this or am I getting to the limitations of tkinter? Thanks for any help.