python gui编程 pdf_Python_GUI程序设计.pdf

Python_GUI程序设计

Python程序设计语言

Python GUI程序设计

张晓 西北工业大学计算机学院

zhangxiao@

2009-11-20

Python GUI编程概述

 PyQT

wxPython

wxPython参考资料

 活学活用wxPython

 http:

Python程序设计语言 2

wxPython是什么

wxPython 实际是两件事物的组合体:

Python 脚本语言和 GUI 功能的

wxWindows 库

wxWindows库是为了最大可移植性的

C/C++ 库,而抽取 GUI 功能

 Windows

 X、KDE 或 Gnome 的 UNIX

 wxPython 应用程序不仅快速和易于编写,而

且可以在不作任何更改情况下,运行在

Windows 或 UNIX 环境下

 http:

Python程序设计语言 3

最小的 wxPython 程序

显示一个空白的窗口,标

题为First Windows

App对象

 Frame对象

import wx

app = wx.PySimpleApp()

frame = wx.Frame(None, -1, "First Windows", size=(300, 300))

frame.Show(True)

app.MainLoop()

Python程序设计语言 4

显示JPG图片

使用image对象

将image对象传递

给frame

class Frame(wx.Frame): #2 wx.Frame子类

"""Frame class that displays an image."""

def __init__(self, image, parent=None, id=-1,

pos=wx.DefaultPosition,

title='Hello, wxPython!'): #3图像参数

"""Create a Frame instance and display image."""

#4 显示图像

temp = image.ConvertToBitmap()

size = temp.GetWidth(), temp.GetHeight()

wx.Frame.__init__(self, parent, id, title, pos, size)

self.bmp = wx.StaticBitmap(parent=self, bitmap=temp)

Python程序设计语言 5

图形设计的基础

应用程序

 窗口

控件

事件处理

Python程序设计语言 6

各对象的生命周期

应用程序

 窗口 控件

事件处理

Python程序设计语言 7

增加一个控件

创建并修改状态栏

statusBar = self.CreateStatusBar() #1 创建状态栏

self.SetStatusText("This is the statusbar")

增加一个Menu

menuBar = wx.MenuB

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值