def create_search_interface(): label1_ = Label(root, text="WELCOME TO THE BEST DICTIONARY", bg="black", fg="red", font=("arial", 20, "bold")) label1_.pack(fill=BOTH, padx=3, pady=23) label2_ = Label(root, text="Enter the Word: ", font=("arial", 10)) label2_.place(x=100, y=140) entry1_ = Entry(root, width=40) entry1_.place(x=200, y=142) entry1_.after(100, entry1.focus()) submit_ = Button(root, text="SUBMIT", bg="red", fg='white', font=('arial', 10), command=button_action) submit_.place(x=240, y=210)
class login: """ classe de base de login-box utile pour une entrée de nouvel utilisateur options standards: -title:le titre de la boite de dialogue(texte) -mask:le caractère qui sera présenté pour cacher les lettre du mot de passe methodes /fonctions: -show: affiche la boite de login et retourne les infos entrées par l'utilisateur """ def __init__(self, title="Log in Box", mask="&"): """Constructor of login Box\nargs:title,selected""" from tkinter import Tk, Frame, Label, Entry, Button, BooleanVar, Checkbutton self.__Entry__ = Entry self.__usr__, self.__pwrd__ = None, None self.__mask__ = mask self.__root__ = Tk() self.__frm__ = Frame(self.__root__) self.__frm__.pack(side="top") self.__frm2__ = Frame(self.__root__) self.__frm2__.pack() self.__root__.title(title) self.__root__.resizable(False, False) self.__lbl_usr__ = Label(self.__frm__, text="User name : ", bd=4, relief="groove", width=13) self.__lbl_usr__.grid(row=1, column=1) self.__lbl_pwrd__ = Label(self.__frm__, text="Password : "******"groove", width=13) self.__lbl_pwrd__.grid(row=2, column=1) self.__lbl_pwrd2__ = Label(self.__frm2__, text="Password again: ", bd=4, relief="groove", width=13) self.__lbl_pwrd2__.grid(row=1, column=1) self.__txt_usr__ = Entry(self.__frm__, width=15) self.__txt_usr__.grid(row=1, column=2) self.__txt_pwrd__ = Entry(self.__frm__, width=15, show=self.__mask__) self.__txt_pwrd__.grid(row=2, column=2) self.__txt_pwrd2__ = Entry(self.__frm2__, width=15, show=self.__mask__) self.__txt_pwrd2__.grid(row=1, column=2) self.__frm___ok_cancel = Frame(self.__root__, width=76) self.__frm___ok_cancel.pack(side="bottom") self.__btn_ok__ = Button(self.__frm___ok_cancel, text="Ok", width=6, command=self.__func_ok__) self.__btn_ok__.pack(side="left", padx=5) self.__var_check__ = BooleanVar(self.__root__, True) self.__check__ = Checkbutton(self.__frm___ok_cancel, text="Hide code", variable=self.__var_check__, command=self.__Check__) self.__check__.pack(side="left", padx=2) self.__btn_cancel__ = Button(self.__frm___ok_cancel, text="Cancel", width=6, command=self.__cancel__) self.__btn_cancel__.pack(side="right", padx=5) self.__root__.bind("<Escape>", self.__cancel__) self.__txt_usr__.bind("<Return>", self.__func_ok__) self.__txt_pwrd__.bind("<Return>", self.__func_ok__) self.__txt_pwrd2__.bind("<Return>", self.__func_ok__) self.__btn_ok__.bind("<Return>", self.__func_ok__) self.__txt_usr__.focus() def __Check__(self, event=None): """Check if checkbutton's value is true or false to show or hide the password and hide or show the password entry""" lst = "", "&" self.__txt_pwrd__.configure(show=lst[self.__var_check__.get()]) if self.__var_check__.get() == 0: self.__frm2__.forget() self.__txt_pwrd__.focus() self.__txt_pwrd2__.destroy() else: self.__txt_pwrd2__ = self.__Entry__(self.__frm2__, width=15, show=self.__mask__) self.__txt_pwrd2__.grid(row=1, column=2) self.__txt_pwrd2__.focus() self.__txt_pwrd2__.bind("<Return>", self.__func_ok__) self.__frm2__.pack() self.__root__.update() def show(self): """show the login box and wait for the user's codes which would be return""" self.__root__.mainloop() return self.__usr__, self.__pwrd__ def __cancel__(self, event=None): """Escape from the login-box""" self.__root__.destroy() def __error__(self, arg): """signal an error to the user""" from winsound import MessageBeep as snd snd(23) arg.configure(bg="red") arg.after(200, lambda col="SystemWindow": arg.configure(bg=col)) arg.focus() pass def __func_ok__(self, event=None): """Central function which defines what to do""" from winsound import MessageBeep as snd self.__usr__, self.__pwrd__ = self.__txt_usr__.get( ), self.__txt_pwrd__.get() pwrd2 = None try: pwrd2 = self.__txt_pwrd2__.get() self.__frm2__.info() show = True except: show = False if self.__usr__ == "": self.__error__(self.__txt_usr__) elif self.__pwrd__ == "": self.__error__(self.__txt_pwrd__) elif pwrd2 == "" and show == True: self.__error__(self.__txt_pwrd2__) pass elif pwrd2 != self.__pwrd__ and show == True: self.__txt_pwrd2__.destroy() self.__txt_pwrd2__ = self.__Entry__(self.__frm2__, width=15, show=self.__mask__) self.__txt_pwrd2__.grid(row=1, column=2) self.__txt_pwrd2__.focus() self.__txt_pwrd2__.bind("<Return>", self.__func_ok__) self.__txt_pwrd2__.after(750, self.__txt_pwrd2__.focus) popup( self.__root__, message="The 2 passwords are not\nthe sames please try again!") else: snd(75) self.__root__.destroy() def __reset__(self): """clear the user-name and the password""" try: self.__txt_usr__.destroy() self.__txt_pwrd__.destroy() except: pass try: self.__txt_usr__ = self.__Entry__(self.__frm__, width=15) self.__txt_usr__.grid(row=1, column=2) self.__txt_usr__.focus() self.__txt_pwrd__ = self.__Entry__(self.__frm__, width=15, show=self.__mask__) self.__txt_pwrd__.grid(row=2, column=2) self.__txt_usr__.bind("<Return>", self.__func_ok__) self.__txt_pwrd__.bind("<Return>", self.__func_ok__) self.__txt_usr__.focus() except: pass try: self.__root__.update() except: pass
anchor='w') # second section section2 = Section(root, text='Second Section') section2.pack(fill='x', expand=True, anchor='nw') line_frame = Frame(section2.sub_frame) line_frame.pack(expand=True, anchor='w') Entry(line_frame, validate='all', validatecommand=(on_change_reg,'%d','%s','%P','%V')).pack(side='left') Button(line_frame, text='Actually Quit', command=root.destroy).pack(side='left') inner_section1 = Section(section2.sub_frame,text='Inner Section 1') inner_section1.pack(fill='x', expand=True, anchor='nw') other_entry = Entry(inner_section1.sub_frame) other_entry.pack(anchor='w') inner_section2 = Section(section2.sub_frame,text='Inner Section 2') inner_section2.pack(fill='x', expand=True, anchor='nw') Label(inner_section2.sub_frame,text='I\'m inside...').pack(anchor='w') # third section section3 = Section(root, text='Third Section') section3.pack(fill='x', expand=True, anchor='nw') Text(section3.sub_frame).pack(anchor='w') root.protocol("WM_DELETE_WINDOW",on_closing) # Start a timer before starting the Tk loop timer_start_time = time.time() other_entry.after(500,tick) root.mainloop()
var3 = IntVar() label1 = Label(root, text="WELCOME TO THE BEST DICTIONARY", bg="black", fg="red", font=("arial", 20, "bold")) label1.pack(fill=BOTH, padx=3, pady=23) label2 = Label(root, text="Enter the Word: ", font=("arial", 10)) label2.place(x=100, y=140) entry1 = Entry(root, width=40) entry1.place(x=200, y=142) entry1.after(100, entry1.focus()) def restart(): root.destroy() python = sys.executable os.execl(python, python, *sys.argv) def create_search_interface(): label1_ = Label(root, text="WELCOME TO THE BEST DICTIONARY", bg="black", fg="red", font=("arial", 20, "bold")) label1_.pack(fill=BOTH, padx=3, pady=23)