PySideで何を作る

Life is Tech!(流山市編)までにアプリ作れるようになっておかないといけないのに
なにもできない、Unityも動かなくなったし ←これまじ辛い
あと、Pygameはゲーム専門なので、使えそうにない
だから、PySideで再挑戦。

import sys
import time
from PySide.QtGui import QWidget,QApplication


class Sample_Win(QWidget):
  """Main Window"""

  def __init__(self):
    QWidget.__init__(self)
    self.setWindowTitle("THe First Program")
    self.setGeometry(400,400,400,400)
    self.setMinimumHeight(100)
    self.setMinimumWidth(250)
    self.setMaximumHeight(200)
    self.setMaximumWidth(800)

if __name__ == '__main__':

  try:
    myApp = QApplication(sys.argv)
    myWindow = Sample_Win()
    myWindow.show()
    print("A") 
#resize the window
    
    time.sleep(2)
    myApp.exec_()
    
    myApp = QApplication(sys.argv)
    myWindow = Sample_Win()
    myWindow.show()
    myWindow.resize(200,200)
    myWindow.setWindowTitle("THE THIRD Prog")
    myWindow.repaint()
    print("C") 
    
    sys.exit(0)

  except NameError:
    print("Name Error: {0}".format(sys.exc_info()[1]))
  except SystemExit:
    print("Closing Window...")
  except Exception:
    print("{0}".format(sys.exc_info()[1]))

これが、Window開くやつ.

import sys
import time
from PySide.QtGui import QWidget,QApplication

これがモジュール

class Sample_Win(QWidget):
  """Main Window"""

  def __init__(self):
    QWidget.__init__(self)
    self.setWindowTitle("THe First Program")
    self.setGeometry(400,400,400,400)
    self.setMinimumHeight(100)
    self.setMinimumWidth(250)
    self.setMaximumHeight(200)
    self.setMaximumWidth(800)

QWidgetっていうのが、
The widget is the center of the user interface. It receives the user inputs from mouse, keyboard, and other events, of the window system, and paints a representation of itself on the screen.


if __name__ == '__main__':

  try:
    myApp = QApplication(sys.argv)
    myWindow = Sample_Win()
    myWindow.show()
    print("A") 
#resize the window
    
    time.sleep(2)
    myApp.exec_()
    
    myApp = QApplication(sys.argv)
    myWindow = Sample_Win()
    myWindow.show()
    myWindow.resize(200,200)
    myWindow.setWindowTitle("THE THIRD Prog")
    myWindow.repaint()
    print("C") 
    
    sys.exit(0)

ちなみにこれ、Linuxだと、2個出てこない。
On executing the program, you will be shown a window as shown in the following image. This window will get resized after 3 seconds. Also, try to resize the window by dragging its corners. You may notice that the window cannot be shrunk or expanded beyond the minimum and maximum metrics set in our earlier code. You might not initially see a window when executing this program on an XWindow based system such as Linux, because the main application loop has not been called yet, so none of the objects has been really constructed and buffered out to the underlying XWindow system.

が理由.

  try
  ...
  except NameError:
    print("Name Error: {0}".format(sys.exc_info()[1]))
  except SystemExit:
    print("Closing Window...")
  except Exception:
    print("{0}".format(sys.exc_info()[1]))

のNameError知らん。
SystemExitはCtrl+cでプロセスを終了させたときに "Closing Window "
って出力される
最後も知らん。