##~ #-------------------------------------------------
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 主程序测试的更多相关文章

  1. C++数据结构之Stack(栈)

    stack,栈,是好比堆积木似的数据结构,从上之下堆积,取出时按"LIFO"-last int first out后进先出的规则.栈一般为线程所独有,也就是每个线程有其自有的栈,与 ...

  2. 利用 C++ 单向链表实现队列

    利用C++ 单向链表实现数据结构队列,其实和上一篇基本内容相同,仅仅是插入的时候在链表的尾部插入,取元素都是一样的,都从头部取. #pragma once #include "stdio.h ...

  3. 栈实现java

    栈是一种“先去后出”的抽象的数据结构.例如:我们在洗盘子的时候,洗完一个盘子,将其放在一摞盘子的最上面,但我们全部洗完后,要是有盘子时,我们会先从最上面的盘子开始使用,这种例子就像栈的数据结构一样,先 ...

  4. java Io流中FileInputStream和BufferedInputStream的速度比较

    首先是对FileInputStream 加上 FileOutputStream 对文件拷贝的应用 我这里拷贝的是一个视频.当然,你们拷贝什么都可以,当文件越大时效果越明显 下面是对BufferedIn ...

  5. 一、Spring Boot 入门

    1.Spring Boot 简介 简化Spring应用开发的一个框架: 整个Spring技术栈的一个大整合: J2EE开发的一站式解决方案: 2.微服务 2014,martin fowler 微服务: ...

  6. python基础知识2---核心风格

    阅读目录 一.语句和语法 二.变量定义与赋值 三.内存管理 内存管理: 引用计数: 简单例子 四.python对象 五.标识符 六.专用下划线标识符 七.编写模块基本风格 八.示范 一.语句和语法 # ...

  7. SpringBoot之基础

    简介 背景 J2EE笨重的开发 / 繁多的配置 / 低下的开发效率 / 复杂的部署流程 / 第三方技术集成难度大 特点 ① 快速创建独立运行的spring项目以及主流框架集成 ② 使用嵌入式的Serv ...

  8. 朱晔和你聊Spring系列S1E6:容易犯错的Spring AOP

    阅读PDF版本 标题有点标题党了,这里说的容易犯错不是Spring AOP的错,是指使用的时候容易犯错.本文会以一些例子来展开讨论AOP的使用以及使用过程中容易出错的点. 几句话说清楚AOP 有关必要 ...

  9. python程序编写简介

    语句和语法 # 注释 \ 转译回车,继续上一行,在一行语句较长的情况下可以使用其来切分成多行,因其可读性差所以不建议使用 : 将两个语句连接到一行,可读性差,不建议使用 : 将代码的头和体分开 语句( ...

随机推荐

  1. 判断网络是否连接 和 判断GPS是否连接

    //判断网络是否连接 public static Boolean isNetworkEnabled(Context context){ int status=-1  //设置默认连接的状态为-1 Co ...

  2. 深入理解KMP算法

    前言:本人最近在看<大话数据结构>字符串模式匹配算法的内容,但是看得很迷糊,这本书中这块的内容感觉基本是严蔚敏<数据结构>的一个翻版,此书中给出的代码实现确实非常精炼,但是个人 ...

  3. POJ 1226 后缀数组

    题目链接:http://poj.org/problem?id=1226 题意:给定n个字符串[只含大小写字母],求一个字符串要求在n个串或者他们翻转后的串的出现过.输出满足要求的字符串的长度 思路:根 ...

  4. PHP public private protected 三种修饰符的区别

    public 表示全局,类内部外部子类都可以访问:private表示私有的,只有本类内部可以使用:protected表示受保护的,只有本类或子类或父类中可以访问:

  5. Codeforces Round #349

    终于又回到熟悉的Round了 数学 A - Pouring Rain 设个未知数,解方程,还好没有hack点 #include <bits/stdc++.h> typedef long l ...

  6. POST和GET的区别

    1. get是从服务器上获取数据,post是向服务器传送数据.2. get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看到.post是通过H ...

  7. Eclipse: Resource is out of sync with the file system when publishing to tomcat server on Eclipse

    Link: http://stackoverflow.com/questions/4343735/avoiding-resource-is-out-of-sync-with-the-filesyste ...

  8. JStorm之Nimbus简介

    本文导读: ——JStorm之Nimbus简介 .简介 .系统框架与原理 .实现逻辑和代码剖析 )Nimbus启动 )Topology提交 )任务调度 )任务监控 .结束语 .参考文献 附:JStor ...

  9. [转]shell 变量替换

    转自:http://blog.csdn.net/xuhongning/article/details/6191515 1,参数替换: 不含有“:”的,只要定义了,就生效,不管是否为空 含有“:”的,即 ...

  10. hdu2612 Find a way

    Problem Description Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. L ...