在Windows里搭建Python的GTK+环境搭建注意事项
在Windows里搭建Python的GTK+环境还是比较麻烦的有以下几个注意事项
1、PyGTK网站上下的包,可能没有Glade类(Lib\site-packages\gtk-2.0\gtk目录下没有glade.pyd),如果没有这个类你就无法在程序里导入Glade工具创建的xml,手写界面还是挺麻烦的。
2、GTK网站上的GTK包,没有包括Glade的DLL文件,还是无法读入Glade的xml文件
所以要按如下方法来搭建GTK+环境
1、安装Python,最好是2.6.5这个版本支持的比较全面
2、从http://ftp.acc.umu.se/pub/GNOME/binaries/win32/下载最新的GTK+包,解压到你自己的目录,并设置系统路径
3、从http://ftp.acc.umu.se/pub/GNOME/binaries/win32/下载最新的pycairo, pygtk, pygobject, 安装到Python的目录下,做为第三方包
4、从http://ftp.acc.umu.se/pub/GNOME/binaries/win32/下载最新的pango, libglade, glib, 解压到GTK+的目录下
经过以上4步,GTK+环境就应该可以工作了。
相关文档:
Ref : http://www.swig.org/translations/chinese/tutorial.html
假设你有一些c你想再加Python.。举例来说有这么一个文件example.c
/* File : example.c */
#include <time.h>
double My_variable = 3.0;
int fact(int n) {
if (n <= 1) return 1;
&nbs ......
先说python
python的random模块提供了多个伪随机数发生器,默认都是用当前时间戳为随机数种子。
下面是该模块几个最常用的函数
random() Return the next random floating point number in the range [0.0, 1.0).
randint(a,b) Return a random integer N such that a <=
N <= b
randrange([star ......
def MergeSort(mylist, low, mid, high):
i = low
j = mid + 1
tmp = []
while i <= mid and j <= high:
if mylist[i] <= mylist[j]:
tmp.append(mylist[i])
i = i + 1
else:
tmp.append(mylist[j])
j = j + 1
......
1. Building an Application with PyGTK and Glade
2. Creating a GUI using PyGTK and Glade
3. A Beginner's Guide to Using pyGTK and Glade
4. Is there a walkthrough on getting PyGTK2 and libglade2 to work on win32 ......