#-*- coding: UTF-8 -*-
__author__ = '007'
__date__ = '2016/4/5'
from Tkinter import *
classmorse2char():
char_morse={}
morse_char={}
morse_num={}
char_num={}def __init__(self):
self.root=Tk()
self.root.title("MORSE码查询器")
self.frm=Frame(self.root)#top
Label(self.root,text="MORSE码查询器", bg="green", fOnt=('Arial',15)).pack()
self.morse_table()#left
self.frm_L =Frame(self.frm)
self.frm_LT=Frame(self.frm_L)
self.var_char=StringVar()
Entry(self.frm_LT, textvariable=self.var_char, 字符", bg="yellow", fOnt=('Arial',12)).pack(side=LEFT)
self.frm_LT.pack(side=TOP)
self.var_L_char=StringVar()
self.lb_char= Listbox(self.frm_L, selectmode=BROWSE, listvariable=self.var_L_char, fOnt=('Verdana',12), 清除", command=self.clear, 查询", command=self.search, morse码", bg="pink", fOnt=('Arial',12)).pack(side=RIGHT)
self.frm_RT.pack(side=TOP)
self.var_R_morse=StringVar()
self.lb_morse= Listbox(self.frm_R, selectmode=BROWSE, listvariable=self.var_R_morse, fOnt=('Verdana',12), 请选择或输入")
self.var_char.set('')
self.var_morse.set('')defmorse_table(self):
f= file('./morse_query')for line inf:
chunk= line.strip().split(' ')#print chunk
self.char_morse[chunk[0]] = chunk[1]
self.morse_char[chunk[1]] =chunk[0]
self.char_num= sorted(self.char_morse.iteritems(), key = lambda asd:asd[1])
self.morse_num= sorted(self.morse_char.iteritems(), key = lambdaasd:asd[0])defmain():
m=morse2char()
mainloop()if __name__ == "__main__":
main()