title: Animating a rectangle in PyQT5: Why is QtCore not defined?
body: <p>I am trying to animate a rectangle in PyQT by creating an animation loop. I have done this in TKinter using the <code>window.after()</code> method and am trying to do the same thing in PyQt5 using <code>QtCore.QTimer.singleShot()</code>, however, when I run the code it says that <code>QtCore</code> is not defined yet I believe that I have imported it!? Also - would this method work anyway? Is there a better method?</p>
  
  <pre><code>import sys
  from PyQt5.QtWidgets import *
  from PyQt5.QtGui import *
  from PyQt5.Qt import *
  from PyQt5.QtCore import *
  
  
  def animate():
      global a
      global x
      mw.paintEvent = paintEvent
      a = a+1
      x = x+1
      QtCore.QTimer.singleShot(33, animate)
  
  
  def paintEvent(e):
      qp = QPainter()
      qp.begin(mw)
      qp.setBrush(QColor(200, 0, 0))
      qp.drawRect(a, b, x, y)
      qp.end()
  
  a = 10
  b = 15
  x = 90
  y = 60
  
  app = QApplication(sys.argv)
  
  mw = QMainWindow()
  mw.setWindowTitle('PyQt5 - Main Window')
  mw.setWindowIcon(QIcon("icon.jpg"))
  mw.resize(300,100)
  
  animate()
  
  mw.show()
  sys.exit(app.exec_())
  </code></pre>