玩转树莓派-RaspBerry,使用Python开发定制界面

1 准备SD卡8G以上,16G更佳。

    编译过程中,会耗用大量存储空间。一定在编译之前运行sudo raspi-config,选择expand file system扩展SD卡的分区。

    如果空间不够,会导致运行挂起。使用df -h可查看存储卡的可用容量。

2 更新资源的索引清单

sudo apt-get update (从服务上下载索引清单)
sudo apt-get upgrade (比较索引清单,更新依赖关系)

3 安装 python-dev

sudo apt-get install python-dev

    否则在编译SIP时,会提示 fatal error: Python.h: No such file or directory

4 安装libqt4-dev

sudo apt-get install libqt4-dev
#或者
sudo apt-get install qt4-dev-tools

    否则在编译PyQt时会提示 Error:Make sure you have a working Qt qmake on your PATH or use the -q argument to explicitly specify a working Qt qmake 5。

    依次安装SIP和PyQt。

    安装SIP:

wget http://sourceforge.net/projects/pyqt/files/sip/sip-4.16.6/sip-4.16.6.tar.gz
tar vxf sip-4.16.6.tar.gz
cd sip-4.16.6
python configure.py
make
make install

    安装PyQt4:

#wget http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10/PyQt-x11-gpl-4.10.tar.gz
wget http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.4/PyQt-x11-gpl-4.10.4.tar.gz/download
cp download PyQt-x11-gpl-4.10.4.tar.gz  
tar vxf PyQt-x11-gpl-4.10.4tar.gz
cd PyQt-xll-gpl-4.10.4
python configure.py
make
make install


5 运行Python&GUI的源代码

    进入PyQT下面的Examples目录,使用python *.py方式运行。

    下面这张图是周末两天的成果,虽说很是简陋,但运行成功的一刻,一切都值得了:)。

玩转树莓派-RaspBerry,使用Python开发定制界面_第1张图片



你可能感兴趣的:(python,qt,树莓派,raspberry)