Chinaunix首页 | 论坛 | 博客
  • 博客访问: 212704
  • 博文数量: 67
  • 博客积分: 3156
  • 博客等级: 中校
  • 技术积分: 650
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-18 17:41
个人简介

软件工程师!

文章分类

全部博文(67)

文章存档

2015年(1)

2014年(1)

2012年(6)

2011年(16)

2010年(31)

2009年(12)

分类: Python/Ruby

2009-12-10 16:45:10

1.安装pygtk及gtk运行时库(run time library)

   我所选择的安装版本是

   python 2.5.2 (下载地址 )

   python gtk+ (下载地址 )

   PyCairo

   PyGObject

   PyGTK

  以上就是python开发gtk+必需的三个python包,虽说是py2.6结尾(意思是支持python 2.6,但是也支持python 2.5~~)

   python gtk+的官网与资源

   重要的第二步就是GTK+运行时库了!

   GTK+运行时库

   这一步也会让人迷惑,有太多的包选择了!

   全部下载太麻烦了!

   所有有一个 bundle打包下载全部的gtk+运行时库

  

   这个包的大小是27M多!

   我把python gtk+所依整的所有动态库都取出来,做了一个小小的包,下载4M就可以了!

   及其python安装包全部打包

   下载地址为

2.配置gtk库为windows path的搜库路径

   比较拙的方法是把bundle的bin目录下的所有dll拷贝到system32(不支持这种做法)!

   修改windows系统的环境变量,将bundle的bin加入path搜索路径!

   如图(我使用的是我抽出来的lib库)

2.pygtk写的"hello workd"

#!/usr/bin/env python

""" Simple Hello World example similar to the GTK+ Tutorials one """

import gtk

def hello(*args):
    """ Callback function that is attached to the button """
    print "Hello World"
    window.destroy()

def destroy(*args):
    """ Callback function that is activated when the program is destoyed """
    window.hide()
    gtk.main_quit()

# this block creates our main application window
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("destroy", destroy)
window.set_border_width(10)

# this block creates our button and places it within the window
button = gtk.Button("Hello World")
# connects the 'hello' function to the clicked signal from the button
button.connect("clicked", hello)
window.add(button)
button.show()

# as the button is within the window this also shows the window
window.show_all()
gtk.main()

运行效果!



阅读(897) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~