Still continue to write the Python gadget, think of before using Tkinter to be half dead, decided to change a framework to write the UI, but also want to know about Qt, learn about PYQT4
Build the Environment
Win: Now install package http://www.riverbankcomputing.co.uk/software/pyqt/download, test environment is WIN8 64-bit, Python2.7, so download the Pyqt4-4.11.3-gpl-py2.7-qt4.8.6-x64.exe , all the way next, it's easy to note that the installation package automatically searches for the Python installation location and installs it to the python27\lib\ The Site-packages\pyqt4 directory. Reference: http://www.2cto.com/kf/201111/111625.html
Mac: Need to download qt, Sip, PYQT4, local environment is OS 10.9.2 64-bit, QT 5.3, qt self-download self-installation can
Sip:http://www.riverbankcomputing.co.uk/software/sip/download I downloaded the sip-4.16.6.tar.gz in Source Packages, install:
1 cd sip-4.16. 6 2 3 python configure.py-d/library/python/2.7/site-packages--arch=x86_6445 make67 sudo make install
Pyqt:http://www.riverbankcomputing.com/software/pyqt/download I downloaded the development snapshots. Pyqt-mac-gpl-4.11.4-snapshot-8313084030e1.tar.gz. Install the following (PYQT directory and QT installation directory to change to your specific directory):
1 cd pyqt-mac-gpl-4.11. 4-snapshot-8313084030e123 python configure-ng.py-q/users/watsy/qt5.3 /5.3/clang_64/bin/qmake-d/library/python/2.7/site-packages/--sip/system/library/ frameworks/python.framework/versions/2.7/bin/sip45 make 6 7 sudo make install
MAC Environment Construction Reference: http://blog.csdn.net/watsy/article/details/8857252
Python's UI file using QT
Set up the environment, you can use the designer designer to easily create a UI interface, under Windows in the Python27\lib\site-packages\pyqt4 directory, Mac under the QT installation directory Qt5.3.0/5.3/clang_ 64/bin under
The suffix of the designer-generated UI file is. UI, Command: Pyuic4-x aaaaaaa.ui-o bbbbbb.py You can turn the. ui file into a py file. (You can CD to the directory where the. ui file is located, or you can enter the absolute path to the. ui file)
Note: Windows can open cmd.exe direct input PYUIC4 command, Mac to set the PYUIC4 environment variables, otherwise you can only take the path, such as:
/volumes/mac_data/soft/pyqt-mac-gpl-4.11.4-snapshot-83d48b092f7c/pyuic4-x Aaaaaaa.ui-o bbbbbb.py
Python PYQT Connection Custom parameters
In response to some of the control's signals, if you want to pass some custom parameters in, you need to encapsulate the signal, such as:
1 self.callback1 = partial (Self.on _click, U walk 364351asdf " " 2 #self. Connect ( Ui.pushbutton, SIGNAL ( clicked () " ", Self.callback1) 3 Ui.pushButton.clicked.connect (self.callback1) 4 5 def on_click_common1 (self, str1):/ Span>7 print (str1)
For details, refer to: http://askandstudy.blog.163.com/blog/static/1997520582012013195282/
Pyqt4 one of the learning: setting up the environment and getting started