text: #!/usr/bin/python
  # -*- coding: utf-8 -*-
  
  """
  ZetCode PyQt4 tutorial 
  
  This program centers a window 
  on the screen. 
  
  author: Jan Bodnar
  website: zetcode.com 
  last edited: October 2011
  """
  
  import sys
  from PyQt4 import QtGui
  
  
  class Example(QtGui.QWidget):
      
      def __init__(self):
          super(Example, self).__init__()
          
          self.initUI()
          
      def initUI(self):               
          
          self.resize(250, 150)
          self.center()
          
          self.setWindowTitle('Center')    
          self.show()
          
      def center(self):
          
          qr = self.frameGeometry()
          cp = QtGui.QDesktopWidget().availableGeometry().center()
          qr.moveCenter(cp)
          self.move(qr.topLeft())
          
          
  def main():
      
      app = QtGui.QApplication(sys.argv)
      ex = Example()
      sys.exit(app.exec_())
  
  
  if __name__ == '__main__':
      main()