modifiedvalues 主程序测试
##~ #-------------------------------------------------
class InputFrame(wx.Frame):
def __init__(self,title='InputFrame:',label='Setting values:',values={'int':1,'String':'This is String','float':3.5},size=(400,200)):
'''''
#~ >>>IFrame = InputFrame(title='InputFrame:',label='Setting values:',values={'int':1,'String':'This is String','float':3.5},size=(400,200)):
#~>>> rvalues=IFrame.GetValue()
'''
wx.Frame.__init__(self,parent=None,title = title,size=size)
self.modifiedvalues=values.copy()
self.IPL = InputPanel(self,label=label,values=values)
#~ #创建FlexGridSizer
self.FlexGridSizer=wx.FlexGridSizer( rows=9, cols=1, vgap=5,hgap=5)
self.FlexGridSizer.SetFlexibleDirection(wx.BOTH)
self.RightPanel = wx.Panel(self,-1)
#~ #测试按钮1
self.Button1 = wx.Button(self.RightPanel,-1,"TestButton",size=(100,40),pos=(10,10))
self.Button1.Bind(wx.EVT_BUTTON,self.GetValue)
#~ #加入Sizer中2881064151
self.FlexGridSizer.Add(self.Button1,proportion =0, border = 5,flag = wx.ALL | wx.EXPAND)
self.RightPanel.SetSizer(self.FlexGridSizer)
self.BoxSizer=wx.BoxSizer(wx.HORIZONTAL)
self.BoxSizer.Add(self.IPL,proportion =-10, border = 2,flag = wx.ALL | wx.EXPAND)
self.BoxSizer.Add(self.RightPanel,proportion =0, border = 2,flag = wx.ALL | wx.EXPAND)
self.SetSizer(self.BoxSizer)
self.Center(wx.BOTH)
#~ #按钮事件,用于测试
def GetValue(self,event):
self.modifiedvalues=self.IPL.GetValue()
#~ print(self.modifiedvalues)
return self.modifiedvalues
#~ #主程序测试
def TestInputFrame():
app = wx.PySimpleApp()
title='InputFrame:'
label='Setting values:'
values={'int':234,'String':'This is String','float':3.5}
frame =InputFrame(title,label,values)
frame.Show()
app.MainLoop()
return
if __name__ == '__main__':
app = wx.PySimpleApp()
title='InputFrame:'
label='Setting values:'
values={'int':234,'String':'This is String','float':3.5}
frame =InputFrame(title,label,values)
frame.Show()
app.MainLoop()
#-*- coding:utf-8 -*-
#~ #--------------------------------------------------------------------------------
#~ module:wlab
#~ FileName=WInput.py
#~ Funciton:wx的输入对话框
#~ author:吴徐平
#~ Date:2013-04-28
#~ Email:539688300@qq.com
#~ #-------------------------------------------------
import wx
import wx.lib.sized_controls as wxsc
#~ #-------------------------------------------------
#~ #set value for widgets( StaticText and TextCtrl) height
wh=30
#~ #set value for max width times
mwt=8
#~ #set value for wh times
wht=3
#~ #-------------------------------------------------
class InputDialog(wxsc.SizedDialog):
def __init__(self,title='Setting values:',values={'int':1,'String':'This is String','float':3.5}):
'''
#~ using it as follow:
#~ dialog = InputDialog(title='Setting values:',values={'int':1,'String':'This is String','float':3.5})
#~ just for test:
#~ dialog = InputDialog()
'''
style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
wxsc.SizedDialog.__init__(self,parent=None, id=-1, title=title, style=style)
self.originvalues=values.copy()
self.modifiedvalues=values.copy()
self.pane = self.GetContentsPane()
self.pane.SetSizerType("form")
maxlen1=mwt*max([len(str(key)) for key in values])
if maxlen1<wh*wht:
maxlen1=wh*wht
maxlen2=mwt*max([len(str(values[key])) for key in values])
if maxlen2<wh*wht:
maxlen2=wh*wht
for key in self.modifiedvalues:
keyStr=str(key)
label=keyStr+' :'
StaticText = wx.StaticText(parent=self.pane,id=-1,label=label,style=wx.ALIGN_RIGHT)
StaticText.SetInitialSize((maxlen1,wh))
value=str(self.modifiedvalues[key])
TextCtrl = wx.TextCtrl(parent=self.pane, id=-1,value=value)
TextCtrl.SetInitialSize((maxlen2,wh))
TextCtrl.SetSizerProps(expand=True)
#~set a name for TextCtrl,so later we can use wx.FindWindowByName()
TextCtrl.Name='TC_'+str(keyStr)
#StaticText.Name='ST_'+str(keyStr)
#~ # add dialog buttons
self.SetButtonSizer(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL))
self.Fit()
self.Center()
def GetOriginValue(self):
'''
#~ if the user select wx.ID_CANCEL,then return originvalues
'''
return self.originvalues
def GetValue(self):
'''
#~ if the user select wx.ID_OK,then return self.modifiedvalues
'''
for key in self.modifiedvalues:
keyStr=str(key)
TextCtrlName='TC_'+str(keyStr)
TextCtrl=self.FindWindowByName(TextCtrlName)
ovk=self.modifiedvalues[key]
if(type(ovk)==int):
self.modifiedvalues[key]=int(TextCtrl.GetValue().strip())
elif(type(ovk)==float):
self.modifiedvalues[key]=float(TextCtrl.GetValue().strip())
else:
self.modifiedvalues[key]=str(TextCtrl.GetValue())
return self.modifiedvalues
#~ #-------------------------------------------------
def InputBox(title='Setting values',values={'int':1,'String':'This is String','float':3.5}):
'''
#~ >>>values={'int':1,'String':'This is String','float':3.5}
#~ >>>title='Setting values:'
#~ >>>rvalues=InputBox(title,values)
#~ >>>print(rvalues):
'''
app = wx.PySimpleApp()
dialog = InputDialog(title=title,values=values)
if dialog.ShowModal() == wx.ID_OK:
values= dialog.GetValue()
else:
values=dialog.GetOriginValue()
dialog.Destroy()
app.MainLoop()
return values
##~ #测试InputBox
#if __name__ == '__main__':
#values={'int':1,'String':'This is String','float':3.5}
#title='Setting values'
#rvalues=InputBox(title,values=values)
#print(rvalues)
##~ #-------------------------------------------------
class InputPanel(wx.Panel):
def __init__(self,parent,label='Setting values:',values={'int':1,'String':'This is String','float':3.5}):
'''
#~ >>>ipl = InputPanel(parent,label='Setting values:',values={'int':1,'String':'This is String','float':3.5})
#~>>> rvalues=ipl.GetValue(self)
'''
wx.Panel.__init__(self,parent=parent, id=-1)
self.modifiedvalues=values.copy()
box = wx.StaticBox(self, -1, label=label)
sbsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
gridsizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
maxlen1=mwt*max([len(str(key)) for key in values])
if maxlen1<wh*wht:
maxlen1=wh*3
maxlen2=mwt*max([len(str(values[key])) for key in values])
if maxlen2<wh*wht:
maxlen2=wh*wht
for key in self.modifiedvalues:
keyStr=str(key)
label=keyStr+' :'
StaticText = wx.StaticText(parent=self,id=-1,label=label,style=wx.ALIGN_RIGHT)
StaticText.SetInitialSize((maxlen1,wh))
gridsizer.Add(StaticText, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 3)
value=str(self.modifiedvalues[key])
TextCtrl = wx.TextCtrl(parent=self, id=-1,value=value)
TextCtrl.SetInitialSize((maxlen2,wh))
gridsizer.Add(TextCtrl, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 3)
#~set a name for TextCtrl,so later we can use wx.FindWindowByName()
TextCtrl.Name='TC_'+str(keyStr)
sbsizer.Add(gridsizer, 1, wx.EXPAND)
gridsizer.Layout()
PanelSizer = wx.BoxSizer(wx.VERTICAL)
PanelSizer.Add(sbsizer, 0, wx.ALL|wx.EXPAND, 5)
self.SetSizer(PanelSizer)
PanelSizer.Layout()
PanelSizer.Fit(self)
def GetValue(self):
'''
#~ return self.modifiedvalues
'''
for key in self.modifiedvalues:
keyStr=str(key)
TextCtrlName='TC_'+str(keyStr)
TextCtrl=self.FindWindowByName(TextCtrlName)
ovk=self.modifiedvalues[key]
if(type(ovk)==int):
self.modifiedvalues[key]=int(TextCtrl.GetValue().strip())
elif(type(ovk)==float):
self.modifiedvalues[key]=float(TextCtrl.GetValue().strip())
else:
self.modifiedvalues[key]=str(TextCtrl.GetValue())
return self.modifiedvalues
##~ #-------------------------------------------------
class InputFrame(wx.Frame):
def __init__(self,title='InputFrame:',label='Setting values:',values={'int':1,'String':'This is String','float':3.5},size=(400,200)):
'''
#~ >>>IFrame = InputFrame(title='InputFrame:',label='Setting values:',values={'int':1,'String':'This is String','float':3.5},size=(400,200)):
#~>>> rvalues=IFrame.GetValue()
'''
wx.Frame.__init__(self,parent=None,title = title,size=size)
self.modifiedvalues=values.copy()
self.IPL = InputPanel(self,label=label,values=values)
#~ #创建FlexGridSizer
self.FlexGridSizer=wx.FlexGridSizer( rows=9, cols=1, vgap=5,hgap=5)
self.FlexGridSizer.SetFlexibleDirection(wx.BOTH)
self.RightPanel = wx.Panel(self,-1)
#~ #测试按钮1
self.Button1 = wx.Button(self.RightPanel,-1,"TestButton",size=(100,40),pos=(10,10))
self.Button1.Bind(wx.EVT_BUTTON,self.GetValue)
#~ #加入Sizer中
self.FlexGridSizer.Add(self.Button1,proportion =0, border = 5,flag = wx.ALL | wx.EXPAND)
self.RightPanel.SetSizer(self.FlexGridSizer)
self.BoxSizer=wx.BoxSizer(wx.HORIZONTAL)
self.BoxSizer.Add(self.IPL,proportion =-10, border = 2,flag = wx.ALL | wx.EXPAND)
self.BoxSizer.Add(self.RightPanel,proportion =0, border = 2,flag = wx.ALL | wx.EXPAND)
self.SetSizer(self.BoxSizer)
self.Center(wx.BOTH)
#~ #按钮事件,用于测试
def GetValue(self,event):
self.modifiedvalues=self.IPL.GetValue()
#~ print(self.modifiedvalues)
return self.modifiedvalues
#~ #主程序测试
def TestInputFrame():
app = wx.PySimpleApp()
title='InputFrame:'
label='Setting values:'
values={'int':234,'String':'This is String','float':3.5}
frame =InputFrame(title,label,values)
frame.Show()
app.MainLoop()
return
if __name__ == '__main__':
app = wx.PySimpleApp()
title='InputFrame:'
label='Setting values:'
values={'int':234,'String':'This is String','float':3.5}
frame =InputFrame(title,label,values)
frame.Show()
app.MainLoop()
modifiedvalues 主程序测试的更多相关文章
- C++数据结构之Stack(栈)
stack,栈,是好比堆积木似的数据结构,从上之下堆积,取出时按"LIFO"-last int first out后进先出的规则.栈一般为线程所独有,也就是每个线程有其自有的栈,与 ...
- 利用 C++ 单向链表实现队列
利用C++ 单向链表实现数据结构队列,其实和上一篇基本内容相同,仅仅是插入的时候在链表的尾部插入,取元素都是一样的,都从头部取. #pragma once #include "stdio.h ...
- 栈实现java
栈是一种“先去后出”的抽象的数据结构.例如:我们在洗盘子的时候,洗完一个盘子,将其放在一摞盘子的最上面,但我们全部洗完后,要是有盘子时,我们会先从最上面的盘子开始使用,这种例子就像栈的数据结构一样,先 ...
- java Io流中FileInputStream和BufferedInputStream的速度比较
首先是对FileInputStream 加上 FileOutputStream 对文件拷贝的应用 我这里拷贝的是一个视频.当然,你们拷贝什么都可以,当文件越大时效果越明显 下面是对BufferedIn ...
- 一、Spring Boot 入门
1.Spring Boot 简介 简化Spring应用开发的一个框架: 整个Spring技术栈的一个大整合: J2EE开发的一站式解决方案: 2.微服务 2014,martin fowler 微服务: ...
- python基础知识2---核心风格
阅读目录 一.语句和语法 二.变量定义与赋值 三.内存管理 内存管理: 引用计数: 简单例子 四.python对象 五.标识符 六.专用下划线标识符 七.编写模块基本风格 八.示范 一.语句和语法 # ...
- SpringBoot之基础
简介 背景 J2EE笨重的开发 / 繁多的配置 / 低下的开发效率 / 复杂的部署流程 / 第三方技术集成难度大 特点 ① 快速创建独立运行的spring项目以及主流框架集成 ② 使用嵌入式的Serv ...
- 朱晔和你聊Spring系列S1E6:容易犯错的Spring AOP
阅读PDF版本 标题有点标题党了,这里说的容易犯错不是Spring AOP的错,是指使用的时候容易犯错.本文会以一些例子来展开讨论AOP的使用以及使用过程中容易出错的点. 几句话说清楚AOP 有关必要 ...
- python程序编写简介
语句和语法 # 注释 \ 转译回车,继续上一行,在一行语句较长的情况下可以使用其来切分成多行,因其可读性差所以不建议使用 : 将两个语句连接到一行,可读性差,不建议使用 : 将代码的头和体分开 语句( ...
随机推荐
- HTTP 请求方式: GET和POST的比较(转)
GET和POST是HTTP的两个常用方法. 什么是HTTP? 超文本传输协议(HyperText Transfer Protocol -- HTTP)是一个设计来使客户端和服务器顺利进行通讯的协议 ...
- Gym 100814C Connecting Graph 并查集+LCA
Description standard input/output Statements Alex is known to be very clever, but Walter does not be ...
- SpringMVC中向服务器传递时间参数时出现的问题
1. 问题描述: 今天在SpringMVC应用中上传参数的时候遇到如下问题: The request sent by the client was syntactically incorrect 这说 ...
- C#解决从含身份证号码的Excel表格导入数据库的问题
用C#做从Excel表导入SQL数据库时发现从EXCEL导入的身份证号码会变成科学表示方法. 解决这个问题是比较容易的,首先,打开电子表格,选中“身份证号码”一列,右键选择“设置单元格格式”,进入单元 ...
- 2014-2015 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)
I. Sale in GameStore(贪心) time limit per test 2 seconds memory limit per test 512 megabytes input sta ...
- 桌面每日一句--桌面翻译工具(有道翻译,微软翻译,Google翻译)
现在的翻译软件功能越来越多,也越来越臃肿,还不时弹广告,真的很烦恼. 鉴于这种情况,自己做了个翻译软件,能满足日常需求就好了.需要用的时候可以直接在桌面输入单词翻译,或者直接使用快捷键呼出翻译窗口.最 ...
- Reids 主从同步
安装Redis(主从两个装在同一服务器上) 参考地址:http://www.cnblogs.com/kgdxpr/p/3550633.html 主安装在“/usr/local/redis-Master ...
- ACM: 强化训练-Beautiful People-最长递增子序列变形-DP
199. Beautiful People time limit per test: 0.25 sec. memory limit per test: 65536 KB input: standard ...
- 转载:冷门js技巧
前端已经被玩儿坏了!像console.log()可以向控制台输出图片等炫酷的玩意已经不是什么新闻了,像用||操作符给变量赋默认值也是人尽皆知的旧闻了,今天看到Quora上一个帖子,瞬间又GET了好多前 ...
- win8.1上wamp环境中利用apache自带ab压力测试工具使用超简单讲解
2015.10.4apache自带ab压力测试工具使用:本地环境:win8.1 wampserver2.5 -Apache-2.4.9-Mysql-5.6.17-php5.5.12-64b 可以参考一 ...