#!/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的更多相关文章

  1. wxpython绘制折线图

    environment:win10 + eclipse + pydev + python2.7.11 + wxpython3.0.2 code sample: #!/usr/bin/env pytho ...

  2. wxPython 自动提示文本框

    1.原版和例子都在这里 在浏览器的地址栏,或者在百度.google 输入文字的时候,输入框的下面会把有关的项目都提示出来. wxPython 没有提供类似的控件,google 了一下,发现了一个,很好 ...

  3. wxPython入门练习代码 二

    WxPython书籍[摘记] 1.任何wxPython应用程序都需要一个应用程序对象.这个应用程序对象必须是类wx.App或其定制的子类的一个实例.2.在OnInit()方法中将至少创建一个框架对象, ...

  4. wxPython入门练习代码 一

    Bare.py: #1.导入必须的wxPython包 import wx #2.子类化wx应用程序类 class App(wx.App): #3.定义应用程序初始化方法 def OnInit(self ...

  5. wxPYTHON图形化软件开发(一)---LOMO工具箱

    最近学了wxPYTHON,这次就做了一个工具箱软件练手,软件主要是包含各种小工具,目前想到的有密码管理器,日记本,记账本,今天还看到一个网页浏览器,也可能加进来.目前实现的是密码管理器 软件GUI部分 ...

  6. 移动端自动化环境搭建-wxpython的安装

    安装wxpython A.安装依赖 wxPython 是 Python 非常有名的一个 GUI 库,因为 RIDE 是基于这个库开发的,所以这个必须安装. B.安装过程 下载地址:http://www ...

  7. 教程和工具--用wxPython编写GUI程序的

    wxPython是个很好的GUI库,对底层的C++库进行了封装,调用起来很方便,尤其是操作前台UI界面和后台多线程,两者配合很方便,做GUI程序最难是写界面尤其是布局. 关于wxPython,自己正在 ...

  8. wxPython:事件

    事件──── 是每个 GUI 应用不可舍割的一部分,因为所有的 GUI 应用程序都是基于事件驱动的.从 GUI 程序启动开始,它就回应同户的不同类型的事件.除了用户,也有其它因素可以产生事件,例如:互 ...

  9. wxPython+Boa Constructor环境配置

    配置之前先完成eclipse + Pydev的配置环境.详见http://www.cnblogs.com/dflower/archive/2010/05/13/1734522.html 1. 安装 w ...

  10. wxpython 基本的控件 (文本)

    wxPython 工具包提供了多种不同的窗口部件,包括了本章所提到的基本控件.我们涉及静态文本.可编辑的文本.按钮.微调.滑块.复选框.单选按钮.选择器.列表框.组合框和标尺.对于每种窗口部件,我们将 ...

随机推荐

  1. 【Git版本控制】git中reset命令的详解

    git reset 命令详解(一) git reset 命令详解(二) reset命令的语法:git reset [选项]  [版本号]  [要回退的目标] 选项:--soft仅将head指针指向历史 ...

  2. (72)zabbix监控日志文件 MySQL日志为例

    一般情况下,日志最先反映出应用当前的问题,在海量日志里面找到我们异常记录,然后记录下来,并且根据情况报警,大家可以监控系统日志.nginx.Apache.业务日志. 这边我拿常见的MySQL日志做监控 ...

  3. Unity基础-脚本的优化

    脚本的优化 object pool 避免频繁的内存分配和gc噩梦(字符串相加?) 是否有必要都写在update里?分帧? 需要的只取一次 使用editor内赋值,而不是find 复杂的物理 复杂的数学 ...

  4. VMware12全新安装CentOS-6.9模板机(已优化)

    1.从安装系统开始准备 安装中添加网卡 eth0 ip 10.0.0.210 netmask 24 gateway 10.0.0.254 DNS servers 223.5.5.5 eth1 ip 1 ...

  5. 【 android】When an app is installed on the external storage

    When an app is installed on the external storage: The .apk file is saved to the external storage, bu ...

  6. Python语言的简介

    ___________________________________________________________我是一条分割线__________________________________ ...

  7. phpmyadmin提示The mbstring extension is missing的解决方法

    解决办法:安装php-mbstring yum install php-mbstring

  8. Wannafly挑战赛21 机器人

    从前在月球上有一个机器人.月球可以看作一个 n*m 的网格图,每个格子有三种可能:空地,障碍,机器人(有且仅有一个),现在地面指挥中心想让机器人在月球上行走,每次可以发送一个指令,为 U-往上走.D- ...

  9. 关于C#Debug和Release

    在程序调试时的debug和release 网上有如下的描述:Debug 通常称为调试版本,它包含调试信息,并且不作任何优化,便于程序员调试程序.Release 称为发布版本,它往往是进行了各种优化,使 ...

  10. LA 7048 Coprime 莫比乌斯反演

    题意: 给出\(n(n \leq 10^5)\)个数字\(a_i(a_i \leq 10^5)\),从中选出\(3\)个数,使得这\(3\)个数两两互质或者两两不互质 分析: 可以说这是<训练指 ...