title: Tkinter: optimize canvas object movement
body: <p>I wrote this really simple code that move an oval trough the screen:</p>
  
  <pre><code>from tkinter import *
  
  """ GLOBAL VARS """
  H, W = 400, 600  # default height / width
  DELAY = 30  # frame rate in milliseconds
  R = 20  # radius of the ball
  
  
  class App:
      def __init__(self, parent):
          """ app init """
          self.root = parent
          self.canvas = Canvas(self.root, bg="white", height=H, width=W)
          self.canvas.pack()
  
          self.pos = [W / 2, H / 2]  # starting position
          self.speed = [2, 2]  # x / y speed
  
          self.canvas.create_oval(self.pos[0] - 20, self.pos[1] - 20, self.pos[0] + 20, self.pos[1] + 20, fill="blue")
  
          self.loop()
  
  
      def loop(self):
          """ main loop """
          coords = self.canvas.coords(1)[:2]  # actual oval coordinates
  
          if not 0 &lt; coords[0] &lt; W - 20:  # the oval bounce off the window
              self.speed[0] *= -1
          if not 0 &lt; coords[1] &lt; H - 20:
              self.speed[1] *= -1
  
          self.canvas.move(1, *self.speed)
  
          self.root.after(DELAY, self.loop)
  
  
  """ GUI SETUP """
  root = Tk()
  App(root)
  root.mainloop()
  </code></pre>
  
  <p>The problem is that when I try to increase the frame rate, the oval half disappears (I tried to take some screenshots, but when I do, the app freezes for one frame and in the screenshots the oval appears correctly, btw you can try yourself by running the code above).</p>
  
  <p>My question is: is there a way to optimize the motion or do I have to accept the fact that Tkinter can't handle high fps?</p>