Download code.py
  1. '''
  2. Created on Aug 21, 2011
  3.  
  4. @author: abiusx
  5. '''
  6. import sys
  7. # Importing the necessary Qt classes.
  8.  
  9. from PyQt4.QtGui import QLabel, QApplication
  10. # We use the from foo import * syntax here because
  11. # all of Qt's objects begin with a Q
  12. # and thus we shouldn't run into namespace problems.
  13.  
  14. if __name__=='__main__':
  15.  
  16. App = QApplication(sys.argv)
  17.  
  18. # All Qt programs need an
  19. # QApplication instance.
  20.  
  21. # We pass the sys.argv as its arguments
  22. # because Qt is adept at handling some
  23. # of the default command-line options
  24. # like style, size, etc by itself.
  25.  
  26. Label = QLabel( "Hello World!" )
  27.  
  28. # QLabel is the class providing a
  29. # simple label
  30.  
  31. Label.show()
  32.  
  33. # Like in most GUI toolkits, we have
  34. # to manually set it to show
  35.  
  36. App.exec_()
  37.  
  38. # Notice the _ after exec, this is to
  39. # avoid the confusion with Python's
  40. # exec() built-in-function
  41.  
  42. # exec_() starts the main application
  43. # loop. Something like main() of other
  44. # toolkits.