title: Calling paintEvent() from a class in pyqt4 python
body: <p>I have written a class to display rectangles (the cell class). I would like to have functions inside the class to call in another class (i.e. calling <code>cell.paintEvent(self,event)</code> and <code>cell.drawRectangles(self,qp)</code> in a function defined in a Window class). Unfortunately, I do not know how to call these functions in another class (i.e. Window) as they both require arguments (i.e. <code>event</code> and <code>pq</code>) and I do not know what to pass on to them.</p>
  
  <p>Here is the code for my cell class:</p>
  
  <pre><code>class cell(object):
      def __init__(self, c, x, y, w, h, active,flux_val,index):
  
          self.c1 = c
          self.c2 = c
          self.c3 = 255
          self.x = x
          self.y = y
          self.w = w
          self.h = h
          self.index = index
          self.active = active
          self.flux_val = flux_val
          self.isChecked = False
          self.isHit = False
  
      def paintEvent(self, e):
  
          qp = QtGui.QPainter()
          qp.begin(self)
          self.drawRectangles(qp)
          qp.end()
  
      def drawRectangles(self, qp):
  
          color = self.c2
          #qp.setPen(color)
  
          qp.setBrush(color)
          qp.drawRect(self.x, self.y, self.w, self.h)
  </code></pre>
  
  <p>Here is the part of the code (specifically <code>def.initiate(self)</code>) where I want to instantiate an array of cell objects ( which I can easily do) and then call its relevant display functions (i.e. <code>cell.paintEvent(self,event)</code> and <code>cell.drawRectangles(self,qp)</code>, which I still have not figured out how to do):</p>
  
  <pre><code>import sys
  from PyQt4 import QtGui, QtCore
  import numpy as np
  
  
  class Window(QtGui.QMainWindow):
      def __init__(self):
          super(Window, self).__init__()
          self.setGeometry(50, 50, 1000, 800)
          self.setWindowTitle("PyQT tuts!")
          self.initiate()
          self.show()
  
      def initiate(self):
          #initiate an array of cell objects
          #Call their display functions (or any other relevant class functions)
  </code></pre>