This is a static archive of the Python wiki, which was retired in February 2026 due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.

Previewing a form

On the #pyqt channel on Freenode, a_l_e asked for a way to preview a main window form created in Qt Designer.

   1 import sys
   2 
   3 from PyQt4.QtGui import QApplication
   4 from PyQt4.uic import loadUi
   5 
   6 if __name__ == "__main__":
   7 
   8     app = QApplication(sys.argv)
   9     
  10     if len(app.arguments()) != 2:
  11     
  12         sys.stderr.write("Usage: %s <ui file>\n" % app.arguments()[0])
  13         sys.exit()
  14     
  15     window = loadUi(app.arguments()[1])
  16     window.show()
  17     sys.exit(app.exec_())

2026-02-14 16:12