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

#沒法輸入,只能粘貼進去html

相關文章
相關標籤/搜索