码迷,mamicode.com
首页 > 编程语言 > 详细

wxPython

时间:2014-08-31 17:01:01      阅读:352      评论:0      收藏:0      [点我收藏+]

标签:http   os   使用   io   strong   ar   for   art   div   

wxPython是python GUI的工具箱。

一, 安装

http://wiki.wxpython.org/How%20to%20install%20wxPython

稳定的wxpython 需要python 2.7版本,所以最好是用2.7

ptyhon2.7下载地址:

https://www.python.org/downloads/   我装的是32 位的

然后下载wxpython 直接安装就OK了。

http://www.wxpython.org/download.php    你上面python安装多少位的 这里就下载多少位的

 

我是在win下使用的。

下面开始介绍如何使用wxpython

#!/usr/bin/env python
import wx

app = wx.App(False)  # Create a new app, don‘t redirect stdout/stderr to a window.
frame = wx.Frame(None, wx.ID_ANY, "Hello World") # A Frame is a top-level window.
frame.Show(True)     # Show the frame.
app.MainLoop()

Explanations:

app = wx.App(False)

Every wxPython app is an instance of wx.App. For most simple applications you can use wx.App as is. When you get to more complex applications you may need to extend the wx.App class. The "False" parameter means "don‘t redirect stdout and stderr to a window".

wx.Frame(None,wx.ID_ANY,"Hello")

A wx.Frame is a top-level window. The syntax is x.Frame(Parent, Id, Title). Most of the constructors have this shape (a parent object, followed by an Id). In this example, we use None for "no parent" and wx.ID_ANY to have wxWidgets pick an id for us.

frame.Show(True)

We make a frame visible by "showing" it.

app.MainLoop()

Finally, we start the application‘s MainLoop whose role is to handle the events.

 

 

 

by freemao

FAFU

free_mao@qq.com

 

wxPython

标签:http   os   使用   io   strong   ar   for   art   div   

原文地址:http://www.cnblogs.com/freemao/p/3947739.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!