import tkinter as tk
from tkinter import ttk
import pyttsx3
engine = pyttsx3.init()
# 字首、字根、字尾選項
t ='ante,contra,contro,counter,a,auto,bene,con,co,com,col,de,en,ex,extra,homo,hyper,in,im,inter,intra,intro,mal,micro,mono,multi,ob,op,para,per,poly,re,semi,sub,sup,super,supra,sur,sym,syn,tele,trans,anti,dis,ab,in,il,ir,im'
t = t.split(',')
t.sort()
prefixes = t
t1 = 'ann,audi,bio,cap,ceive,cip,cept,ced,ceed,cess,cede,circ,cyc,dem,demo,dict,divid,duc,equ,flect,flex,form,gram,graph,gress,ject,manu,mob,mot,mov,nov,ped,pict,port,pos,press,rupt,scribe,serve,sist,spec,spir,spire,tain,tract,vid,vise,viv,volv,volute,uni,bi,tri,oct,deca,cent,kilo,mega'
t1 = t1.split(',')
t1.sort()
roots = t1
t2 = 'er,or,an,ian,ant,ent,ar,ate,ee,eer,ese,ess,ic,ician,ist,ster,al,age,ance,ence,ancy,ency,dom,hood,ic(s),ism,ity,ty,logy,ment,ness,ory,ship,tion,ation,sion,ure,ture,ate,en,fy,ify,ish,ize,ise,le,able,ible,al,ant,ent,ar,ary,ate,en,ful,ic,ical,id,ior,ish,ive,less,like,ly,ous,proof,ward,y,ly,ward(s),way(s),wise'
t2 = t2.split(',')
t2.sort()
suffixes = t2
# 建立主視窗
root = tk.Tk()
root.title("字根組合器")
root.geometry("550x250")
# 設定標籤
tk.Label(root, text="選擇字首:").grid(row=0, column=0, padx=10, pady=10)
tk.Label(root, text="選擇字根:").grid(row=0, column=1, padx=10, pady=10)
tk.Label(root, text="選擇字尾:").grid(row=0, column=2, padx=10, pady=10)
tk.Label(root, text="組合的單字:").grid(row=4, column=0, padx=10, pady=10)
# 建立 Combobox 下拉選單
prefix_var = tk.StringVar()
prefix_combobox = ttk.Combobox(root, textvariable=prefix_var, values=prefixes, state="readonly")
prefix_combobox.grid(row=1, column=0, padx=10, pady=10)
root_var = tk.StringVar()
root_combobox = ttk.Combobox(root, textvariable=root_var, values=roots, state="readonly")
root_combobox.grid(row=1, column=1, padx=10, pady=10)
suffix_var = tk.StringVar()
suffix_combobox = ttk.Combobox(root, textvariable=suffix_var, values=suffixes, state="readonly")
suffix_combobox.grid(row=1, column=2, padx=10, pady=10)
# 顯示組合後的單字
word_label = tk.Label(root, text="", font=("Arial", 14, "bold"), fg="blue")
word_label.grid(row=4, column=1, padx=10, pady=10)
# 更新單字的函式
def update_word():
prefix = prefix_var.get()
root_word = root_var.get()
suffix = suffix_var.get()
combined_word = f"{prefix}{root_word}{suffix}"
word_label.config(text=combined_word)
engine.say(combined_word)
engine.runAndWait()
# 設定按鈕,點擊後更新顯示
combine_button = tk.Button(root, text="組合單字", command=update_word)
combine_button.grid(row=3, column=1, padx=10, pady=10)
# 啟動主循環
root.mainloop()
沒有留言:
張貼留言