-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpfaGUI2.py
More file actions
53 lines (43 loc) · 1.15 KB
/
Copy pathpfaGUI2.py
File metadata and controls
53 lines (43 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 9/30/2018 2:52 PM
# @Author : Aries
# @Site :
# @File : pfaGUI2.py
# @Software: PyCharm
from functools import partial as pto
from tkinter import Tk,Button,X
from tkMessageBox import showinfo,showwarning,showerror
WARN='warn'
CRIT='crit'
REGU='gegu'
SIGNS={
'do not enter':CRIT,
'railroad crossing':WARN,
'55\nspeed limit':REGU,
'wrong way':CRIT,
'merging traffic':WARN,
'one way':REGU
}
critCB=lambda:showerror(
'Error','Error Button Pressed!'
)
warnCB=lambda:showwarning(
'Warning Button Pressed!'
)
infoCB=lambda:showinfo(
'Info','Info Button Pressed!'
)
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()')
eval(cmd)
top.mainloop()