Python大控件——Pmw——是合成的控件,以Tkinter控件为基类,是完全在Python内写的。它们可以很方便地增加功能性的应用,而不必写一堆代码。特别是,组合框和内部确认计划的输入字段放在一起是个很有用的控件。
1.关于框(AboutDialog)

from tkinter import *
import Pmw root=Tk() Pmw.aboutversion("1.5")
Pmw.aboutcopyright('Copyright Company Name 1999\nAll rights reserved')
Pmw.aboutcontact(
'For information about this application contact:\n' +
' Sales at Company Name\n' +
' Phone: (401) 555-1212\n' +
' email: info@company_name.com'
) about=Pmw.AboutDialog(root,applicationname="") root.mainloop()

2.输入域
一个输入域(entry field)包含一个entry控件和多种可验证的选项。验证由一个函数执行,该函数将输入的文本作为第一个参数,并且返回三种标准值的一种,标志输入文本是否合法:
Pmw.OK:输入文本合法
Pmw.ERROR:文本非法无法显示,entry将恢复之前存储的合法的值
Pmw.PARTIAL:文本有部分合法,文本将加上用以表示输入错误的背景。

函数参数
·command
·errorbackground
默认是pink,指定输入非法或部分合法文本时,显示的背景色
·extravalidators
·invalidcommand
当输入非法文本时执行该函数,当使用setentry()设置一个非法文本,该函数也会被调用
·labelmargin
·labelpos
初始化选项,指定label组件放置在何处,如果非None,它应该是“n”,"s","e","w",中的一个或两两组合。第一个字母指定label放置在大控件的那一边,如果第二个字母也指定了,那么它表示在那一边的什么位置放置label。比如,如果labelpos是“w”,label将放置在大控件左边的中间位置;如果是“wn”,label将被放置在左边的顶部。
如果为None,那么label将不会被创建。它的默认值为None
·modifiedcommand
当entry里的值被修改时调用
·sticky
初始化选项,默认为"ew
·value
初始化选项,指定entry中初始化内容
·validate
指定使用哪种验证

Pmw.EntryField

from tkinter import *
import Pmw
root = Tk()
root.option_readfile('optionDB')
root.title('EntryField')
Pmw.initialise() noval = Pmw.EntryField(root, labelpos=W, label_text='No validation',
validate = None) real = Pmw.EntryField(root, labelpos=W, value = '98.4',
label_text = 'Real (96.0 to 107.0):',
validate = {'validator' : 'real',
'min' : 96, 'max' : 107, 'minstrict' : 0}) int = Pmw.EntryField(root, labelpos=W, label_text = 'Integer (5 to 42):',
validate = {'validator' : 'numeric',
'min' : 5, 'max' : 42, 'minstrict' : 0},
value = '')
date = Pmw.EntryField(root, labelpos=W, label_text = 'Date (in 2000):',
value = '2000/1/1', validate = {'validator' : 'date',
'min' : '2000/1/1', 'max' : '2000/12/31',
'minstrict' : 0, 'maxstrict' : 0,
}) widgets = (noval, real, int, date) for widget in widgets:
widget.pack(fill=X, expand=1, padx=10, pady=5)
Pmw.alignlabels(widgets)
real.component('entry').focus_set() root.mainloop()

3.浮动图(Balloon)

from tkinter import *
import Pmw
root=Tk()
Pmw.initialise()
balloon=Pmw.Balloon(root)
frame=Frame(root)
frame.pack(padx=10,pady=5)
field=Pmw.EntryField(frame,labelpos="w",label_text="Name") field.setentry("A.N.Other")
field.pack(side=LEFT,padx=10) balloon.bind(field,"Your name","Enter your name") check=Button(frame,text="check")
check.pack(side=LEFT,padx=10) balloon.bind(check,"Look up","Check if name is in the database") messageBar=Pmw.MessageBar(root,entry_width=40,entry_relief=GROOVE,labelpos=W,label_text="Status:") messageBar.pack(fill=X,expand=1,padx=10,pady=5)
balloon.configure(statuscommand=messageBar.helpmessage) root.mainloop()

4.按钮框

from tkinter import *
import Pmw
root=Tk()
Pmw.initialise() def buttonPress(btn):
print("The %s button was pressed"%btn) def defaultKey(event):
buttonBox.invoke() buttonBox=Pmw.ButtonBox(root,labelpos="nw",label_text="ButtonBox:")
buttonBox.pack(fill=BOTH,expand=1,padx=10,pady=10) buttonBox.add("OK",command=lambda b="ok":buttonPress(b))
buttonBox.add("Apply",command=lambda b="Apply":buttonPress(b))
buttonBox.add("Cancel",command=lambda b="Cancel":buttonPress(b)) buttonBox.setdefault("OK")
root.bind("<Return>",defaultKey)
root.focus_set()
buttonBox.alignbuttons()
root.mainloop()

5.组合框

from tkinter import *
import Pmw
root=Tk() choice=None def choseEntry(entry):
print("You chose %s"%entry)
choice.configure(text=entry) asply=("The Mating of the Wersh","Two Netlemeng of Verona","Twelfth Thing","The Chamrent of vanice","Thamle","Ring Kichard the Thrid") choice=Label(root,text="Choose play",relief="sunken",padx=20,pady=20)
choice.pack(expand=1,fill="both",padx=8,pady=8) combobox=Pmw.ComboBox(root,label_text="Play:",labelpos="wn",
listbox_width=24,dropdown=1,
selectioncommand=choseEntry,
scrolledlist_items=asply)
combobox.pack(fill=BOTH,expand=1,padx=8,pady=8)
combobox.selectitem(asply[0])

Pmw大控件的更多相关文章

  1. Pmw大控件(二)

    Pmw大控件英文名Pmw Python megawidgets 官方参考文档:Pmw 1.3 Python megawidgets 一,如何使用Pmw大控件 下面以创建一个计数器(Counter)为例 ...

  2. wpf 大控件 打印 将控件转成 xps格式 并分页打印

    //PayRollPrintList:要打印的 list 可换成自己要打印的类型 private List<PayRoll> _PayRollPrintList = new List< ...

  3. Material Design Support 8大控件介绍

    TextInputLayout 显示提示信息 能够通过调用setError()在EditText以下显示一条错误信息 FloatingActionButton 悬浮操作按钮 Snackbar 相当于底 ...

  4. Android 布局之LinearLayout 子控件weight权重的作用详析(转)

    关于Android开发中的LinearLayout子控件权重android:layout_weigh参数的作用,网上关于其用法有两种截然相反说法: 说法一:值越大,重要性越高,所占用的空间越大: 说法 ...

  5. Android 布局之LinearLayout 子控件weight权重的作用详析

    关于Android开发中的LinearLayout子控件权重android:layout_weigh参数的作用,网上关于其用法有两种截然相反说法: 说法一:值越大,重要性越高,所占用的空间越大: 说法 ...

  6. winform布局 FlowLayoutPanel的控件

    http://www.cnblogs.com/moon-mountain/archive/2011/09/08/2171232.html 1.采用流布局:工具箱里边容器里有一个:FlowLayoutP ...

  7. [WP8.1UI控件编程]Windows Phone大数据量网络图片列表的异步加载和内存优化

    11.2.4 大数据量网络图片列表的异步加载和内存优化 虚拟化技术可以让Windows Phone上的大数据量列表不必担心会一次性加载所有的数据,保证了UI的流程性.对于虚拟化的技术,我们不仅仅只是依 ...

  8. Atitit.hybrid混合型应用 浏览器插件,控件的实现方式 浏览器运行本地程序的解决方案大的总结---提升用户体验and开发效率..

    Atitit.hybrid混合型应用 浏览器插件,控件的实现方式 浏览器运行本地程序的解决方案大的总结---提升用户体验and开发效率.. 1. hybrid App 1 1.1. Hybrid Ap ...

  9. Atitit. BigConfirmTips 控件 大数据量提示确认控件的原理and总结O9

    Atitit. BigConfirmTips 控件 大数据量提示确认控件的原理and总结O9 1. 主要的涉及的技术 1 2. 主要的流程 1 3. 调用法new confirmO9t(); 1 4. ...

随机推荐

  1. 124-PHP类析构函数

    <?php class myclass{ //定义一个类 public function __destruct(){ //定义析构方法 echo '析构方法执行.<br />'; } ...

  2. 第三节MapStruct翻译--Defining a mapper

    第三节MapStruct--Defining a mapper 在这一章节你将学到如何用mapstruct和它的一些必要的操作选项来定义一个bean mapper. 3.1 Basic mapping ...

  3. C#无边框应用

    引用using System.Runtime.InteropServices; 在窗体的全局模式下输入 [DllImport("user32.dll")] public stati ...

  4. 换根dp

    感觉这类问题很少?算了,还是拿出来水一下吧qwq... 首先来看一道例题:POJ3585 一句话题意:树上任意源点多汇点最大流 你看这不就是个最大流的板子题吗?我先建个图,然后跑最大流,然后,,,然后 ...

  5. 吴裕雄--天生自然C++语言学习笔记:C++ 数字

    下面是一个 C++ 中定义各种类型数字的综合实例: #include <iostream> using namespace std; int main () { // 数字定义 short ...

  6. weex框架

    weex优势: (1)支持ES6规范 (2)性能优异,开发简介标准,提及小巧. (3)跨平台 weex调试工具:weexplayground weex环境搭建: (1)安装 node.js.npm ( ...

  7. 63.Python中contains和icontains

    1. contains: 进行大小写敏感的判断,某个字符串是否包含在指定的字段中,这个判断条件使用大小写敏感进行判断,因此在被翻译成"SQL"语句的时候,会使用"like ...

  8. java中的字符串String

    一.String简介d 参考:https://www.cnblogs.com/zhangyinhua/p/7689974.html String类代表字符串. java.lang.String: Ja ...

  9. CKeditor上传图片 实现所见即所得界面

    迟了好多天的分享,CKeditor这个编辑器虽然不错,但也真苟啊,搞图片上传这个功能,快给我搞佛系了,话不多说,上代码 1.首先去官网下载一个full的版本,我用的是CKeditor 4.13,解压之 ...

  10. js获取浏览器窗口大小

    摘抄:https://blog.csdn.net/qq_27628085/article/details/81947478 常用: JS 获取浏览器窗口大小       // 获取窗口宽度   if ...