title: How to integrate Pygame and PyQt4?
body: <p>I'm using python 2.7 and Ubuntu 14.04.</p>
  
  <p>I'm trying to do <a href="http://www.pygame.org/docs/ref/display.html#pygame.display.init" rel="noreferrer">this</a> in order to have my pygame window inside my GUI</p>
  
  <blockquote>
    <p><strong>On some platforms it is possible to embed the pygame display into an already existing window. To do this, the environment variable SDL_WINDOWID must be set to a string containing the window id or handle. The environment variable is checked when the pygame display is initialized</strong></p>
  </blockquote>
  
  <p>So this is what I did:    </p>
  
  <pre><code>from PyQt4 import QtGui, QtCore
  import os
  import subprocess
  import sys
  
  class Ui_MainWindow(object):
      def setupUi(self, MainWindow):
      MainWindow.setWindowModality(QtCore.Qt.ApplicationModal)
      MainWindow.setFixedSize(800, 600)
      QtCore.QMetaObject.connectSlotsByName(MainWindow)
      self.iniMap()
  
  def iniMap(self):
      command = "xprop -root _NET_ACTIVE_WINDOW"
      output = subprocess.Popen(["/bin/bash", "-c", command], stdout=subprocess.PIPE)
      activeWindowID = str(output.communicate()[0].decode("utf-8").strip().split()[-1])
      os.environ['SDL_WINDOWID'] = activeWindowID
      import pygame
      pygame.init()
      screen = pygame.display.set_mode((565, 437), pygame.NOFRAME)
  
  class frmMain(QtGui.QMainWindow, Ui_MainWindow):
      def __init__(self, parent=None):
          super(frmMain, self).__init__(parent, flags=QtCore.Qt.FramelessWindowHint)
          self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
          self.setupUi(self)
  
  if __name__ == "__main__":
      app = QtGui.QApplication(sys.argv)
      form = frmMain()
      form.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>But it doesn't work. It only shows my PyQt window. I don't know whether I'm doing something wrong or pygame just cannot be integrated with PyQt</p>
  
  <p>What should I do to get my pygame window embedded in <code>frmMain</code>?</p>
  
  <p>Thank you in advance.</p>