python核心编程-GUI程序之偏函数应用
来源:互联网 发布:抢票的软件 编辑:程序博客网 时间:2024/06/06 00:10
#!/usr/bin/env python# -*- coding: UTF-8 -*- from functools import partial as ptofrom Tkinter import Tk, Button, Xfrom tkMessageBox import showinfo, showwarningWARN = 'warn'CRIT = 'crit'REGU = 'regu'SIGNS = { 'do not enter': CRIT, 'railroad crossing':WARN, '55\nspeed limit':REGU, 'merging traffic':WARN, 'one way':REGU,}critCB = lambda: showerror('Error', 'Error Button Pressed!')warnCB = lambda: showwarning('Warning', 'Warning Button Pressed!')infoCB = lambda: showinfo('Info', 'Info Button Pressond!')top = Tk()top.title('Road Signs')Button(top, text='QUIT', command=top.quit, bg='red', fg='white').pack()MyButton = pto(Button, top)CritButton = pto(MyButton, command=critCB, bg='white', fg='red')WarnButton = pto(MyButton, command=warnCB, bg='goldenrod1')ReguButton = pto(MyButton, command=infoCB, bg='white')for eachSign in SIGNS: signType = SIGNS[eachSign] cmd = '%sButton(text=%r%s).pack(fill=X, expand=True)' % (signType.title(), eachSign, '.upper()' if signType == CRIT else '.title()') print cmd eval(cmd)top.mainloop()
输出:
0 0
- python核心编程-GUI程序之偏函数应用
- python核心编程-GUI程序之标签,按钮,进度条
- python核心编程-第一个GUI程序
- [Python]核心编程之GUI编程(Tkinter)
- [Python]核心编程之GUI编程(其他GUI初探)
- python核心编程-GUI程序之综合实例-简单文件浏览器
- [Python]核心编程之函数
- python核心编程-GUI程序按钮与标签
- python核心编程-GUI例子
- python核心编程之-search函数
- Python核心编程之第一个Python程序
- 偏函数GUI程序
- python核心编程-函数调用
- python核心编程-诊断函数
- python核心编程-filter函数
- python核心编程-map函数
- python核心编程-reduce函数
- python核心编程-partial函数
- Win10无线网络WiFi提示无法连接此网络的原因与解决方案
- 文件簇,文件扇区与flash中扇区及页的关系
- 类簇的设计
- 为什么使用命令行工具进行的提交没有在github主页上显示出来?
- 手把手带你画一个漂亮蜂窝view Android自定义view
- python核心编程-GUI程序之偏函数应用
- java 中println(this)的逻辑
- x265-1.7版本-common/scalinglist.cpp注释
- RHEL CENTOS ORACLE LINUX 7.x设置X11转发到XManager
- Linux---CentOS搭建环境之安装JDK
- iOS(学习3) UITextField 常用属性
- 队列的链式结构实现
- 从机广播本机的地址
- 第六天,UITableView,和cell的基础介绍