wxpython example
#!/usr/bin/env python
#----------------------------------------------------------------------------
# Name: test7.py
# Purpose: A minimal wxPython test program
#
# Author: Robin Dunn
#
# Created: A long time ago, in a galaxy far, far away...
# Copyright: (c) 1998 by Total Control Software
# Licence: wxWidgets license
#---------------------------------------------------------------------------- # NOTE: this sample requires wxPython 2.6 or newer # import the wxPython GUI package
import wx # Create a new frame class, derived from the wxPython Frame.
class MyFrame(wx.Frame): def __init__(self, parent, id, title):
# First, call the base class' __init__ method to create the frame
wx.Frame.__init__(self, parent, id, title) # Associate some events with methods of this class
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_MOVE, self.OnMove) # Add a panel and some controls to display the size and position
panel = wx.Panel(self, -1)
label1 = wx.StaticText(panel, -1, "Size:")
label2 = wx.StaticText(panel, -1, "Pos:")
self.sizeCtrl = wx.TextCtrl(panel, -1, "", style=wx.TE_READONLY)
self.posCtrl = wx.TextCtrl(panel, -1, "", style=wx.TE_READONLY)
self.panel = panel # Use some sizers for layout of the widgets
sizer = wx.FlexGridSizer(2, 2, 5, 5)
sizer.Add(label1)
sizer.Add(self.sizeCtrl)
sizer.Add(label2)
sizer.Add(self.posCtrl) border = wx.BoxSizer()
border.Add(sizer, 0, wx.ALL, 15)
panel.SetSizerAndFit(border)
self.Fit() # This method is called by the System when the window is resized,
# because of the association above.
def OnSize(self, event):
size = event.GetSize()
self.sizeCtrl.SetValue("%s, %s" % (size.width, size.height)) # tell the event system to continue looking for an event handler,
# so the default handler will get called.
event.Skip() # This method is called by the System when the window is moved,
# because of the association above.
def OnMove(self, event):
pos = event.GetPosition()
self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y)) # Every wxWidgets application must have a class derived from wx.App
class MyApp(wx.App): # wxWindows calls this method to initialize the application
def OnInit(self): # Create an instance of our customized Frame class
frame = MyFrame(None, -1, "This is a test")
frame.Show(True) # Tell wxWindows that this is our main window
self.SetTopWindow(frame) # Return a success flag
return True app = MyApp(0) # Create an instance of the application class
app.MainLoop() # Tell it to start processing events
wxpython example的更多相关文章
- wxpython绘制折线图
environment:win10 + eclipse + pydev + python2.7.11 + wxpython3.0.2 code sample: #!/usr/bin/env pytho ...
- wxPython 自动提示文本框
1.原版和例子都在这里 在浏览器的地址栏,或者在百度.google 输入文字的时候,输入框的下面会把有关的项目都提示出来. wxPython 没有提供类似的控件,google 了一下,发现了一个,很好 ...
- wxPython入门练习代码 二
WxPython书籍[摘记] 1.任何wxPython应用程序都需要一个应用程序对象.这个应用程序对象必须是类wx.App或其定制的子类的一个实例.2.在OnInit()方法中将至少创建一个框架对象, ...
- wxPython入门练习代码 一
Bare.py: #1.导入必须的wxPython包 import wx #2.子类化wx应用程序类 class App(wx.App): #3.定义应用程序初始化方法 def OnInit(self ...
- wxPYTHON图形化软件开发(一)---LOMO工具箱
最近学了wxPYTHON,这次就做了一个工具箱软件练手,软件主要是包含各种小工具,目前想到的有密码管理器,日记本,记账本,今天还看到一个网页浏览器,也可能加进来.目前实现的是密码管理器 软件GUI部分 ...
- 移动端自动化环境搭建-wxpython的安装
安装wxpython A.安装依赖 wxPython 是 Python 非常有名的一个 GUI 库,因为 RIDE 是基于这个库开发的,所以这个必须安装. B.安装过程 下载地址:http://www ...
- 教程和工具--用wxPython编写GUI程序的
wxPython是个很好的GUI库,对底层的C++库进行了封装,调用起来很方便,尤其是操作前台UI界面和后台多线程,两者配合很方便,做GUI程序最难是写界面尤其是布局. 关于wxPython,自己正在 ...
- wxPython:事件
事件──── 是每个 GUI 应用不可舍割的一部分,因为所有的 GUI 应用程序都是基于事件驱动的.从 GUI 程序启动开始,它就回应同户的不同类型的事件.除了用户,也有其它因素可以产生事件,例如:互 ...
- wxPython+Boa Constructor环境配置
配置之前先完成eclipse + Pydev的配置环境.详见http://www.cnblogs.com/dflower/archive/2010/05/13/1734522.html 1. 安装 w ...
- wxpython 基本的控件 (文本)
wxPython 工具包提供了多种不同的窗口部件,包括了本章所提到的基本控件.我们涉及静态文本.可编辑的文本.按钮.微调.滑块.复选框.单选按钮.选择器.列表框.组合框和标尺.对于每种窗口部件,我们将 ...
随机推荐
- 使用 CFile 的子类 CStdioFile 的注意事项
目前为止只用到了 ReadString,也了解了一下 WriteString. 由于程序需要,本来程序中是用的CFile, 但是需要逐行读取文件数据,所以谷歌找到了 ReadString 类 —— 继 ...
- 原型与原型继承demo
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- rest_framework之status HTTP状态码
Django Rest Framework有一个status.py的文件 通常在我们Django视图(views)中,HTTP状态码使用的是纯数字,像400,404,200,304等,并不是那么很好理 ...
- Lecture 2
1. Coordinate(坐标) data for GIS real coordinate system:Cartesian coordinate systems(笛卡尔坐标系) from 3D t ...
- MAC系统里安装 Python
首先MAC系统自带Python2.6/2.7.这是因为有些系统文件需要.但是对于我来说,我需要用到Python3,所以需要自己下载安装.这时候,就有一个非常强大的软件 Homebrew.(安装方法见官 ...
- Relu的缺点
Relu不适合梯度过大的的输入 Relu是我们在训练网络时常用的激活函数之一(对我而言没有之一).然而最近发现Relu太脆弱了,经常由于输入的函数梯度过大导致网络参数更新后,神经元不再有激活功能.特别 ...
- 数据结构和算法(What Why How)
数据结构和算法是什么? 从广义上讲,数据结构就是指一组数据的存储结构.算法就是操作数据的一组方法. 从狭义上讲,是指某些著名的数据结构和算法,比如队列.堆.栈.二分查找.动态规划等. 数据结构和算法有 ...
- day08 多线程socket 编程,tcp粘包处理
复习下socket 编程的步骤: 服务端: 1 声明socket 实例 server = socket.socket() #括号里不写 默认地址簇使用AF_INET 即 IPv4 ...
- luogu2756 飞行员配对方案问题
匈牙利 #include <iostream> #include <cstring> #include <cstdio> using namespace std; ...
- Zend Framework 2中如何使用Service Manager
end Framework 2 使用ServiceManager(简称SM)来实现控制反转(IoC).有很多资料介绍了service managers的背景,我推荐大家看看this blog post ...