Python+PySideでGUIプログラミング


PyQtではじめるGUIプログラミングが面白そうだったのでメモ。

OSはWindows 7 Home Premium(64bit)。インストールするPythonのバージョンは、現時点で最新の3.2.3にしました。

 

インストールするもの


python-3.2.3.amd64.msiPython本体)

PySide-1.1.0qt474.win-amd64-py3.2.exeGUIライブラリ)

PyScripter-v2.5.3-x64-Setup.exe統合開発環境

 

ドキュメント


python3.2.3

python2.7.2ja(参考)

PySide

 

インストール


デフォルトの位置にインストールすれば、設定などは特にしなくて大丈夫だと思います。

 

ウィンドを表示


PyScripterを起動して以下を保存して実行。Hello Worldと書かれたウィンドが表示されると思います。

  1. import sys
  2. from PySide.QtCore import *
  3. from PySide.QtGui import *
  4.  
  5. def main():
  6.     app = QApplication(sys.argv)
  7.     # Create a Label and show it
  8.    label = QLabel("Hello World")
  9.     label.show()
  10.     # Enter Qt application main loop
  11.    app.exec_()
  12.     sys.exit()
  13.  
  14. if __name__ == '__main__':
  15.     main()

 

割と楽にGUIアプリが作れそうです。