基本的 Hello World 計劃

import sys
from PyQt4 import QtGui

def window():
   app = QtGui.QApplication(sys.argv)
   w = QtGui.QWidget()
   b = QtGui.QLabel(w)
   b.setText("<h1>Welcome to PyQt4 SO Documentation!</h1>")
   w.setGeometry(100,100,550,65)
   b.move(50,20)
   w.setWindowTitle("PyQt4 Hello World Demo")
   w.show()
   sys.exit(app.exec_())
    
if __name__ == '__main__':
   window()