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 工具包提供了多种不同的窗口部件,包括了本章所提到的基本控件.我们涉及静态文本.可编辑的文本.按钮.微调.滑块.复选框.单选按钮.选择器.列表框.组合框和标尺.对于每种窗口部件,我们将 ...
随机推荐
- python queue - 同步队列类
参考 官网 queue 模块 queue 模块实现多生产者,多消费者队列. 当必须在 ==多个线程之间安全地交换信息== 时,它在线程编程中特别有用. 此模块中的Queue类实现了所有必需的锁定语义. ...
- 前端应该如何去认识http
大家应该都知道http是什么吧,肯定会回答不就是浏览器地址那东西吗,有啥好说的,接下来咱们来深入刨析下http这东西. 什么叫http:超文本传输协议(HTTP)是用于传输诸如HTML的超媒体文档的应 ...
- 【数学 思维题】HDU4473Exam
过程很美妙啊 Problem Description Rikka is a high school girl suffering seriously from Chūnibyō (the age of ...
- numpy中常用的函数
1. power(x1, x2) 对x1中的每个元素求n次方.不会改变x1上午shape. 2. sum(a, axis=None, dtype=None, out=None, keepdims=Fa ...
- Ubuntu Server 18.04 LTS安装
Please choose your preferred language. 选择您喜欢的语言 这里直接选择[English] Keyboard configuration 键盘配置 Please s ...
- PHP网站实现地址URL重定向
网站建设中,通常会用到网站地址URL的重定向,这样的好处是有利于你网站的SEO优化,也就是让你的网站实现伪静态,下面简单介绍一下实现的两种方法: 1.在Apache配置文件中设置重定向 首先找到Apa ...
- Buffered Channels and Worker Pools
原文链接:https://golangbot.com/buffered-channels-worker-pools/ buffered channels 带有缓冲区的channel 只有在缓冲区满之后 ...
- 我的Python分析成长之路6
模块:本质就是.py结尾的文件.从逻辑上组织python代码. 包: 本质就是一个目录,带有__init__.py文件,从逻辑上组织模块. 模块的分类: 1.标准库(内置的模块) 2.开源库(第三方库 ...
- AD采样求平均STM32实现
iADC_read(, &u16NTC_1_Sample_Val_ARR[]); == ui8FirstSampleFlag) { ; i<; i++) { u16NTC_1_Sampl ...
- 解决子线程操作UI的方法