windows下的wxPython开发环境安装与配置

安装文件准备:

安装文件

下载地址

python-2.7.2.msi

http://www.python.org/download/

wxPython2.8-win64-unicode-2.8.12.1-py27.exe
wxPython2.8-win32-docs-demos-2.8.12.1.exe

http://www.wxpython.org/download.php

py2exe-0.6.9.win64-py2.7.amd64.exe

http://sourceforge.net/projects/py2exe/files/

eclipse-SDK-3.6.1-win32-x86_64.zip

http://archive.eclipse.org/eclipse/downloads/index.php

PyDev 2.2.3.zip

http://pydev.sourceforge.net/download.html

jdk-7u1-windows-x64.exe

http://www.oracle.com/technetwork/java/javase/downloads/index.html


Python wxPython 运行环境安装
分别安装python-2.7.2.msiwxPython2.8-win64-unicode-2.8.12.1-py27.exe
wxPython2.8-win32-docs-demos-2.8.12.1.exepy2exe-0.6.9.win64-py2.7.amd64.exe

python安装路径采用默认C:\ Python27,安装完毕后,将这个目录添加到path环境变量中

Pydev开发环境安装
如未安装java,请安装jdk-7u1-windows-x64.exe
解压缩eclipse-SDK-3.6.1-win32-x86_64.zipD:\ eclipse-3.6.1

D:\ eclipse-3.6.1下新建pydev-2.2.3文件夹,再在pydev-2.2.3下新建eclipse文件夹,解压缩PyDev 2.2.3.zipD:\eclipse-3.6.1\pydev-2.2.3\eclipse
D:\eclipse-3.6.1\eclipse下创建一个文件夹“links”并在文件夹下创建文件pydev-2.2.3.link,用记事本打开pydev-2.2.3.link,输入:path=D:/eclipse-3.6.1/pydev-2.2.3

解压后的目录结构如下:

目录结构如下

windows下的wxPython开发环境安装与配置


运行并配置Pydev
双击D:\eclipse-3.6.1\eclipse\eclipse.exe运行eclipse,选择一个workspace,待加载完毕后,打开菜单:Window >> Preferences,在弹出的对话框中,进入Pydev >> Interpreter-Python,点击Auto Config会自动加载Python 运行环境配置
开发wxPython应用
新建一个Pydev Projectproj1,然后新建一个Pydev Moduleapp1.py,输入代码:

Python代码

import wx 

if __name__ == '__main__': 

    app = wx.PySimpleApp() 

    frame = wx.Frame(parent=None) 

    frame.Show(True) 

app.MainLoop()

右击app1.py,选择debug as >> python run 即可运行

python脚本转化成exe
新建模块:convert2exe.py,输入代码:

Python代码 

from distutils.core import setup       

import py2exe                          

setup(windows=[{"script": "app1.py"}]) 

然后运行windowsdos 命令行,切换目录到proj1/src目录下,输入命令:
python convert2exe.py py2exe
Python
会生成dist文件夹,并把依赖dll 等资源拷贝到这个目录,同时生成 app1.exe
双击app1.exe 即可运行

你可能感兴趣的:(wxPython)