python3.7版本下,安装wxpython

        目前支持python的所谓“GUI工具包”(GUI Toolkit)有很多,但是没有一个被认为标准的GUI工具包。而wxpython是最熟悉的跨平台python GUI工具包。

        1、wxpython安装

安装网址:https://pypi.org/project/wxPython/

注意!!一定要看清楚你安装的python版本和所选的wxpython版本。

(1)查看自己安装的python版本。

我下的是python3.7,win64,如下:

(2)进入安装网站后,选择符合的wxpython版本进行下载。

        我选择wxPython-4.0.3-cp37-cp37m-win_amd64.whl

其中,文件命名规则请参考以下引用文字:

File naming conventions:

  • Files with the “*.whl” extension are binary wheel files (https://wheel.readthedocs.org/en/latest/). See below for more info.

  • Files with the “*.tar.gz” extension are compressed tar archives of the Phoenix and wxWidgets source code.

  • The “-docs-.tar.gz” files are compressed archives of the documentation.

For example: wxPython_Phoenix-3.0.3.dev1549+fa6f31f-cp33-cp33m-macosx_10_6_intel.whl

means: - This is the wxPython_Phoenix package - It is version 3.0.3.dev1549+fa6f31f (a development version, with the build number derived from the source control system.) - It is built for CPython version 3.3 - It is built for the macosx operating system - It is built for OSX version 10.6 or greater - It is built for Intel processors.

(3)下载完成后是.whl文件,将文件拷贝到python的安装目录/Scripts文件夹下。

(4)在/Scripts文件夹下运行以下命令:pip install wxPython-4.0.3-cp37-cp37m-win_amd64.whl

以下图片是之前安装的3.7,32位显示的情况。

上述两种情况都显示安装成功!

若出现例如wxPython-4.0.3-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.应当是你版本选的不合适!

        2、测试安装成功

(1)安装成功后进行测试,测试代码如下:

import wx				#导入wx包

app = wx.App()				#创建应用程序对象

win = wx.Frame(None,-1,'install test')	#创建窗体

btn = wx.Button(win, label = 'Button')	#创建Button

win.Show()				#显示窗体

app.MainLoop()				#运行程序

(2)效果如图所示

至此wxpython已经安装完成啦!祝你好运哈!

猜你喜欢

转载自blog.csdn.net/sunshine_lyn/article/details/81054594