Lubuntu12.04安装wxpython及examples(demo)

来源:互联网 发布:张卜天的翻译水平知乎 编辑:程序博客网 时间:2024/05/16 05:26

Lubuntu确实轻量级,快速;我个人在我的老爷机上用比XP快,和WIN7,WIN8(没用过,据说很慢)自然不比了。

先从百科里面贴点介绍:

在LXDE的基础上,有关开发团队紧紧咬住Ubuntu开发时间表,推出了一款新的轻量级Ubuntu发行版,起名为Lubuntu(发音为:lu:bu:ntu:,L为轻量级Lightweight的字头)。


接正题,

1.首先安装wx相关的东西,可以用命令行,也可以用新立德包管理器,搜索wxpython

如下勾选的是python-wxgtk2.8,python-wxtools,python-wxversion三个。


应用后即可正常使用wxpython了,当然,可以在python中import wx试一试^_^


2.安装examples,即demo

显然,对很多人老说用wx写程序光安装wx支持是不够的,需要安装examples这个巨大的宝库,从里面取各种所需的程序来用。

这个安装比较容易,从新立德找到wx2.8-examples安装上。

然后看下 菜单应用->编程 里面有没有wxPython Demo,如果没有,则进入 /usr/share/doc/wx2.8-examples/examples/wxPython/ 执行下unpack_examples.sh(当然最好先看看这里的README)

如果不行,可以参照如下设置,原文链接:

http://forum.ubuntu.org.cn/viewtopic.php?t=22782


使用方法: 
1、下载附件ungzip.py 
2、复制文件到wxpython demo文件目录 
命令如下:sudo cp ungzip.py /usr/share/doc/wx2.8-examples/examples/wxPython/ 
3、命令:cd /usr/share/doc/wx2.8-examples/examples/wxPython/ 
4、命令:sudo python ungzip.py 

脚本成功执行后,请用菜单应用->编程->wxPython Demo菜单打开DEMO。 


附:ungzip.py


#!/usr/bin/env pythonimport os##var_path_old=os.environ["PWD"]##os.chdir(var_path)def ufn_ungzip(var_path,var_ext):     var_listdir=os.listdir(var_path)    var_listdir=[var_file for var_file in var_listdir if os.path.isfile(os.path.join(var_path,var_file))]    var_listdir=[var_file for var_file in var_listdir if not cmp(os.path.splitext(var_file)[-1],(var_ext))]    for var_file in var_listdir:        var_shell='gzip -d %s' %(os.path.join(var_path,var_file))        print var_shell        if not os.system(var_shell):            print var_shell    return Truedef ufn_launcher(var_path,var_file):    if os.path.exists(var_path):        os.unlink(var_path)    f=file(var_path,'w')    f.write(var_file)    f.close()    return Truedef main():    var_ext='.gz'    var_file=None    var_listdir=[]    var_shell=None    var_path=os.getcwd()        if os.path.isdir(var_path):        if ufn_ungzip(var_path,var_ext):            print "gzip -d %s ....ok" %(var_file)     var_listdir=os.listdir(var_path)    var_listdir=[var_file for var_file in var_listdir if os.path.isdir(var_file)]    for var_file in var_listdir:        var_file=os.path.join(var_path,var_file)        if ufn_ungzip(var_file,var_ext):            print "gzip -d %s ....ok" %(var_file)     var_shell='/usr/share/applications/wxpdemo.desktop'    var_file="""\[Desktop Entry]Version=1.0Encoding=UTF-8Name=wxPython DemoComment=wxWidgets Cross-platform C++ GUI toolkit (examples)Terminal=falseExec=python %s/demo.pyIcon=%s/wxpdemo.icoType=ApplicationCategories=Application;Development;StartupNotify=true    """ % (var_path,var_path)    if ufn_launcher(var_shell,var_file):        print "create lanuncher %s ...ok" %(var_shell)if __name__=='__main__':    main()##os.chdir(var_path_old)