#!/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. Unity基础-脚本的优化

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

  2. NFS搭建

    一.环境 nfsserver01:192.168.127.100  centos7.3 nfsclient01:192.168.127.101  centos7.3 二.NFS原理 三.安装测试 1. ...

  3. CSS基础:block,inline和inline-block

    css的display属性是前端开发中非常常见的属性,本文简单介绍下其中比较常用的属性值,即block.inline和inline-block. HTML组件中呈现一片空白区域的组件都可当盒模型(bo ...

  4. wamp开发环境配置之配置Apache虚拟主机

    网站建设人员在本地测试时,常常不是一个网站,那怎么能像输入域名一样在地址栏上面输入“域名”就能本地访问该网站呢?这里就要配置Apache虚拟主机了! 1.找到apache\conf\httpd.con ...

  5. A+B问题的异常解法

    先%XZZ为敬 http://www.cnblogs.com/xzz_233/p/a-plus-b-problem.html 万恶之源:https://www.luogu.org/discuss/sh ...

  6. [POJ 1003] Hangover C++解题

        Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 95164   Accepted: 46128 De ...

  7. 理解依赖注入 for Zend framework 2

    依赖注入(Dependency Injection),也成为控制反转(Inversion of Control),一种设计模式,其目的是解除类之间的依赖关系. 假设我们需要举办一个Party,Part ...

  8. Leetcode33--->Search in Rotated Sorted Array(在旋转数组中找出给定的target值的位置)

    题目: 给定一个旋转数组,但是你不知道旋转位置,在旋转数组中找出给定target值出现的位置:你可以假设在数组中没有重复值出现 举例: (i.e., 0 1 2 4 5 6 7 might becom ...

  9. python+selenium面试题

    selenium中如何判断元素是否存在? selenium中没有提供原生的方法判断元素是否存在,一般我们可以通过定位元素+异常捕获的方式判断. # 判断元素是否存在 try: dr.find_elem ...

  10. Flask_WTForms源码流程(糙版)

    from flask import Flask, render_template, request, redirect # Form# _fields# validate# validata_name ...