title: PyQt Attach a window to an open program on resize/move
body: <p>Using Qt and python, I would like to create a window attached to Chrome that moves when I resize my Chrome window. For now, I can attach to the chrome window on start, but I don't know how I could get a move/resize event of the chrome window to adapt the size of main, which is my QMainWindow.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>import win32gui
  import sys,os,re,getopt
  from PyQt4.QtGui import *
  from PyQt4.QtCore import *
  import win32com.client
  
  def callback(hwnd, main):
      rect = win32gui.GetWindowRect(hwnd)
      x = rect[0]
      y = rect[1]
      w = rect[2] - x
      h = rect[3] - y
      if w&gt;20 and h&gt;20:
          windowName= win32gui.GetWindowText(hwnd)
          if "- Google" in windowName:
              print "Window %s:" % win32gui.GetWindowText(hwnd)
              print "classname %s:" % win32gui.GetClassName(hwnd)
              print "\tLocation: (%d, %d)" % (x, y)
              print "\t    Size: (%d, %d)" % (w, h)
              main.move(x,y+40)
  def main():
      app = QApplication(sys.argv)
      main = QMainWindow(None,Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
      main.resize(200,200)
      main.move(400,400)
      qtextedit= QTextEdit(main)
      qtextedit.resize(200,200)
      qtextedit.setPlainText('Hello world')
      qtextedit.setReadOnly(True)
      main.show()
      win32gui.EnumWindows(callback, main)
      sys.exit(app.exec_())
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <h2>How does the code work ?</h2>
  
  <p>main creates a new QMainWindow, with a qtextedit inside it. Than win32gui.EnumWindows is called, which goes through all open windows. I find the Application I want to attach to with the <strong>windowName</strong>, that contains <strong>"- Google"</strong>. I than move the main window 40px lower than the main window. </p>
  
  <p>The problem is when I move the chrome window, my window doesn't move with it. </p>
  
  <p>Is it possible to catch a move event of other windows ?</p>