I am new with Tkinter, and could not find any answers on why the scaling does not work.
I have a script that moves and zooms on an image while the window is running. The movement works perfectly, although canvas.scale() doesn't do anything.
Here is a snippet:
def GetAttrPositions(char, attrs):
global pos
pos = [10,10,1]
root = tk.Tk()
root.title('Getting Attribute Positions')
root.geometry(f"{char_base.size[0]}x{char_base.size[1]}")
canvas = tk.Canvas(root, width=2000, height=2000)
canvas.pack()
char = tk.PhotoImage(file=f"assets/Chars/{char}.png")
char_image = canvas.create_image(0,0, anchor=tk.NW, image=char)
attr = tk.PhotoImage(file=f"assets/Attr/{attrs[0]['Type']}/{attrs[0]['Name']}.png")
attr_image = canvas.create_image(pos[0], pos[1], anchor=tk.NW, image=attr)
def move(event):
global pos
if event.char == "a":
print('a')
pos[0] -= 2
canvas.move(attr_image, -2, 0)
elif event.char == "d":
print('d')
pos[0] += 2
canvas.move(attr_image, 2, 0)
elif event.char == "w":
print('w')
pos[1] -= 2
canvas.move(attr_image, 0, -2)
elif event.char == "s":
print('s')
pos[1] += 2
canvas.move(attr_image, 0, 2)
elif event.char == "x":
print('x')
pos[2] = pos[2]*2
canvas.scale(attr_image, pos[0], pos[1], 2, 2)
elif event.char == "z":
print('z')
pos[2] = pos[2]/2
canvas.scale(attr_image, pos[0], pos[1], 0.5, 0.5)
root.bind("<Key>", move)
root.mainloop()
P.S. I am sure that it is working, as if I put a wrong offset, then the image moves, but does not scale