0
# Import the required libraries
from tkinter import *
from PIL import Image, ImageTk

# Create an instance of tkinter frame
win = Tk()

# Set the size of the tkinter window
win.geometry("700x350")

# Define a Canvas widget
canvas = Canvas(win, width=600, height=400, bg="white")
canvas.pack(pady=20)

# Add Images to Canvas widget
x = 250
y = 120
image = ImageTk.PhotoImage(Image.open('map.png'))
img = canvas.create_image(x, y, anchor=NW, image=image)

def left(e):
   global x, y
   x -= 0.9
   canvas.coords(img, x, y)

def right(e):
   global x, y
   x += 0.9
   canvas.coords(img, x, y)

def up(e):
   global x, y
   y -= 0.9
   canvas.coords(img, x, y)

def down(e):
   global x, y
   y += 0.9
   canvas.coords(img, x, y)

# Bind the move function
win.bind("<Left>", left)
win.bind("<Right>", right)
win.bind("<Up>", up)
win.bind("<Down>", down)

win.mainloop()

map.png is https://www.dropbox.com/s/wfq4skai66nexxr/map.png?dl=0. If you press left or right arrow keys, you will see the black words look slightly lagging. Is there a way to fix that without changing the 0.9?

planyway
  • 35
  • 6
  • Does this answer your question? [Change mouse pointer speed in Windows using python](https://stackoverflow.com/questions/45100234/change-mouse-pointer-speed-in-windows-using-python) – Faraaz Kurawle Feb 27 '22 at 16:56
  • The circle seems to move perfectly smooth when I run the code. – Bryan Oakley Feb 27 '22 at 17:45
  • l changed the mouse pointer speed to the slowest and the problem still exists. Seems like the root problem is not related to the mouse. I edited the sample codes and now without a mouse, the problem still exists. However, I have no idea how to fix this slightly lagging feeling. – planyway Feb 28 '22 at 08:56
  • I also tried to run the code, and the text does not seem to be flashing for me, it might be something related to your system's capability to render than something with tkinter perhaps. – typedecker Feb 28 '22 at 09:07

0 Answers0