python-生僻字转拼音

 1 from  tkinter import Tk, Text, Button, END, N, GROOVE
 2 from pypinyin import pinyin
 3 root = Tk()
 4 root.geometry('540x200+600+340') #设置窗口大小
 5 root.title('[汉字转拼音] Baylor的程序')  #窗口标题
 6 hztext = Text(root, width=20, height=10, font='微软雅黑,18') #窗口展示
 7 hztext.grid(row=0, column=0) #窗口位置
 8 
 9 #按钮  relief 设置框装饰  command 调用程序
10 Button(root, text='转换', font='微软雅黑,18',relief = GROOVE,command = lambda: pytext.delete('1.0', END) or pytext.insert('1.0', pinyin(hztext.get('1.0', END), heteronym=True)[0:-1])).grid(row=0, column=1)
11 
12 pytext = Text(root, width=20, height=10, font='微软雅黑,18')
13 pytext.grid(row=0, column=2)
14 root.mainloop()
15 
16 #tkinter 介绍: https://www.cnblogs.com/wozijisun/p/8794882.html

#无法输入,只能粘贴进去

 

posted on 2018-08-25 23:34  Baylor_Chen  阅读(715)  评论(0编辑  收藏  举报

导航