My environment is Python 2.6 + pyqt v4.1
The introduction of pyqt will not be mentioned. This procedural code can give you a good understanding of how pyqt is going, so it is unrealistic to write programs, we still need to implement it in an object-oriented way.
My code comments are in Chinese and may not be supported by most python. If you want to run the comments, delete them and run them in idle. This will cause problems, after Python and pyqt are installed, run them in command line mode.
:
After exiting, the printf function will be called to display a line in the command line:
Import sysfrom pyqt4 import qtgui, qtcoreapp = qtgui. qapplication (sys. argv) def printf (): Print 'window has finished ') # The default path is in the same directory of the Code # You can write it as window. setmediawicon (qtgui. qicon ('e: \ Python code \ 1.jpg ') # sets the floating window. settooltip ('this is a window') # Set the floating font style and size qtgui. qtooltip. setfont (qtgui. qfont ('oldenglish ', 10) # display window. show () # create a button q = qtgui. qpushbutton ("quit", window) Q. setgeometry (500,300,) Q. settooltip ('close the same C _())