def main(): ''' word: 当前检索单词 root: TK窗体 counter: 计数器显示控件 text: 单词文本显示控件 ans: 单词释义显示控件 key: 单词检索输入控件 e1, e2, e3, e4: 新单词输入控件 :return: 窗体构建与功能实现 ''' global e1, e2, e3, e4, ans, count, text, counter, key, root, A4recite # <editor-fold desc="窗体整体设置"> root = Tk() # root.iconbitmap('rainbow.ico') root.title('彩虹单词本') root.geometry("850x600") root.resizable(0, 0) # </editor-fold> # <editor-fold desc="调用类"> func = Functions() proc = Running_process(func) # </editor-fold> # <editor-fold desc="背单词模块"> counter = Label(root, fg='#43A102', anchor='se', font=font.Font(family='Helvetica', size=13, weight="bold")) text = Label(root, text='开始背单词吧', font=('Arial', 15, 'bold'), width=20, height=10, wraplength=280) ans = Label(root, text='', font=('Arial', 13), width=30, wraplength=280, justify='left', height=10, anchor='w') Button(root, text="Next", bg='#43A102', fg='white', font=font.Font(family='Helvetica', size=10, weight="bold"), width=15, command=func.Next_Random).grid(row=7, column=0, sticky='n') Button(root, text="Answer", bg='#A2B700', fg='white', font=font.Font(family='Helvetica', size=10, weight="bold"), width=15, command=func.Show_Answer).grid(row=7, column=1, sticky='n') counter.grid(row=0, column=0, pady=10) text.grid(row=2, column=0, rowspan=4) ans.grid(row=2, column=1, rowspan=4, sticky='w', columnspan=2) Button(root, text="Sound", bg='#EED205', fg='white', font=font.Font(family='Helvetica', size=10, weight="bold"), width=15, command=func.Play_Sound).grid(row=7, column=2, sticky='n') Button(root, text="Done it", bg='#cc0000', fg='white', font=font.Font(family='Helvetica', size=10, weight="bold"), width=15, command=func.Done_Words).grid(row=7, column=3, sticky='n') # </editor-fold> # <editor-fold desc="搜索单词模块"> key = Entry(root) Button(root, text="Search", bg='#FF8C05', fg='white', font=font.Font(family='Helvetica', size=10, weight="bold"), width=10, command=func.Search_Word).grid(row=0, column=2, pady=10) key.grid(row=0, column=1, pady=10) # </editor-fold> # <editor-fold desc="上传单词模块"> up_module = LabelFrame(root, text='Upload New Words', height=200, width=260, foreground='#FF8C05', font=font.Font(family='Helvetica', size=10, weight="bold"), relief='ridge') up_module.grid(column=3, row=2, rowspan=4, columnspan=2, padx=20, pady=10, ipadx=5, ipady=10, sticky='s') # up_module.grid_propagate(False) Label(up_module, text="单词:").place(x=75, y=20, anchor="e") Label(up_module, text="词性:").place(x=75, y=60, anchor="e") Label(up_module, text="词义:").place(x=75, y=100, anchor="e") Label(up_module, text="补充信息:").place(x=75, y=140, anchor="e") e1 = Entry(up_module) e2 = Entry(up_module) e3 = Entry(up_module) e4 = Entry(up_module) Button(up_module, bg='#FDD283', fg='white', font=font.Font(family='Helvetica', size=10, weight="bold"), text="Upload", width=15, command=func.Add_Words).place(x=60, y=180, anchor="w") e1.place(x=80, y=20, anchor="w") e2.place(x=80, y=60, anchor="w") e3.place(x=80, y=100, anchor="w") e4.place(x=80, y=140, anchor="w") # </editor-fold> # <editor-fold desc="A4纸背单词模块"> A4recite = LabelFrame(root, text='20 Words One Day Challenge', height=200, width=750, foreground='#43A102', font=font.Font(family='Helvetica', size=10, weight="bold"), relief='ridge') A4recite.grid(column=0, row=8, rowspan=4, columnspan=6, padx=50, pady=20, ipadx=5, ipady=10, sticky='s') e2k = Entry(A4recite) e20 = Entry(A4recite) e301 = Entry(A4recite) e22 = Entry(A4recite) e101 = Entry(A4recite) e23 = Entry(A4recite) e24 = Entry(A4recite) e401 = Entry(A4recite) e31 = Entry(A4recite) e41 = Entry(A4recite) e40 = Entry(A4recite) e21 = Entry(A4recite) e25 = Entry(A4recite) e10 = Entry(A4recite) e501 = Entry(A4recite) e50 = Entry(A4recite) e30 = Entry(A4recite) e201 = Entry(A4recite) e11 = Entry(A4recite) e51 = Entry(A4recite) e50.place(x=350, y=180, anchor="w") e101.place(x=520, y=20, anchor="w") e301.place(x=520, y=100, anchor="w") e30.place(x=350, y=100, anchor="w") e22.place(x=10, y=60, anchor="w") e23.place(x=10, y=100, anchor="w") e31.place(x=180, y=100, anchor="w") e41.place(x=180, y=140, anchor="w") e501.place(x=520, y=180, anchor="w") e10.place(x=350, y=20, anchor="w") e51.place(x=180, y=180, anchor="w") e25.place(x=10, y=180, anchor="w") e201.place(x=520, y=60, anchor="w") e40.place(x=350, y=140, anchor="w") e2k.place(x=10, y=20, anchor="w") e11.place(x=180, y=20, anchor="w") e401.place(x=520, y=140, anchor="w") e20.place(x=350, y=60, anchor="w") e21.place(x=180, y=60, anchor="w") e24.place(x=10, y=140, anchor="w") Button(A4recite, bg='#A2B700', fg='white', font=font.Font(family='Helvetica', size=10, weight="bold"), text="Push", width=8, command=func.Push_Cards).place(x=676, y=100, anchor="w") # </editor-fold> # <editor-fold desc="键盘响应模块"> btn = Button(root, text='button') btn.bind_all('<KeyPress>', proc.eventhandler) # </editor-fold> root.mainloop() # 进入消息循环
text= "Yazdırmak istediğiniz değeri girin ve enter ile sonucu alın, 9 hane çevirir " ) xlabel3.place(x=10, y=125) xlabel4 = Label(Pencere, text="") xlabel4.place(x=10, y=145) xinput = Entry(Pencere, bd=1) xinput.place(x=90, y=10) xinput2 = Entry(Pencere, bd=1, width=75) xinput2.place(x=90, y=40) xbuton = Button(Pencere, text="Yazdır.", command=hesapla) xbuton.bind_all("<KP_Enter>", lambda x: hesapla()) xbuton.bind_all("<Return>", lambda x: hesapla()) # bazı linux sistemlerde Return ve KP_Enter olarak ayrı ayrı kullanılıyor xbuton.place(x=10, y=90) xbuton2 = Button(Pencere, text="Sil.", command=lambda: xinput.delete(0, END)) xbuton2.bind_all("<Delete>", lambda x: xinput.delete(0, END)) xbuton2.place(x=78, y=90) xbuton3 = Button(Pencere, text="Hakkında", command=hakkinda) xbuton3.bind_all("<F1>", lambda x: hakkinda()) xbuton3.place(x=125, y=90) xbuton4 = Button(Pencere, text="Çıkış", command=destroy_me) xbuton4.bind_all("<Escape>", lambda x: destroy_me()) xbuton4.place(x=210, y=90)