Hello ,

When i call a window from the main one , how to hide this one , after calling the second , and define it as a main window , this is the code of the two windows :

def InterfaceDeps():

    global interf1
    interf1 = Toplevel()    
    interf1.geometry("500x400")
    interf1.title('                            Base de données ')  

    f1 = Frame(interf1, bg="blue",  width=500, height=400)
    f1.pack( fill=X, expand=0)

    def lab1dep_mouseover(event):
        lab1dep.config(cursor="hand2")

    def lab1stock_mouseover(event):
        lab1stock.config(cursor="hand2")    

    def lab1autres_mouseover(event):
        lab1autres.config(cursor="hand2")

    def callbackdep(event):

        ParcInfo()

    def callbackstock(event):
        Interface1()

    def callbackautres(event):
        Interface1()

    lab1dep = Label(interf1, text="Departement Informatique" ,bg = "blue" ,font=("times",13),  fg = "white" )
    lab1dep.place ( x=40 , y=200)

    lab1dep.bind("<Button-1>", callbackdep)
    lab1dep.bind("<Enter>", lab1dep_mouseover)

    lab1stock = Label(interf1, text="Gestion de stock" ,bg = "blue" ,font=("times",13), fg = "white" )
    lab1stock.place ( x=250 , y=200)

    lab1stock.bind("<Button-1>", callbackstock)
    lab1stock.bind("<Enter>", lab1stock_mouseover)

    lab1autres = Label(interf1, text="Autres" ,bg = "blue" ,font=("times",13), fg = "white" )
    lab1autres.place ( x=390 , y=200)

    lab1autres.bind("<Button-1>", callbackautres)
    lab1autres.bind("<Enter>", lab1autres_mouseover)

    Quitter = Button(interf1, text = "Quitter" , command = interf1.destroy)
    Quitter.place( x=230, y=350 )

    interf1.after(0,center,interf1)

    interf1.mainloop()
    fenetre.destroy()
    #fenetre.withdraw()



#####################################


fenetre=Tk()
fenetre.geometry("500x400")
fenetre.title('                                     ')

f1 = Frame(fenetre, bg="blue",  width=500, height=400)
f1.pack( fill=X, expand=0)

lab1 = Label(fenetre, text="Gestion de ressources informatiques" , bg = "blue", fg = "white" )
lab1.place ( x=152 , y=25 )

failure_max = 3

global uservar
global passvar

uservar = StringVar()
passvar = StringVar()

Label(fenetre, text = "User name:" , bg = "blue", fg = "white" ).place(x = 66, y = 100)
Label(fenetre, text = "Password:" , bg = "blue", fg = "white" ).place(x = 66, y = 125)

entryu = ttk.Entry(fenetre , textvariable=uservar)
entryu.place (x = 180 , y = 100)

entryp = ttk.Entry(fenetre, show='*', textvariable=passvar)
entryp.place (x = 180 , y = 125)

b = Button(fenetre, borderwidth=2, text="Login", width=7, pady=0, command=checkpass)#, image=photo, compound=CENTER)#, state=DISABLED)
b.place(x = 220 , y = 160)

frame21 = Frame(fenetre , bg="blue",    width=40, height=40)
frame21.pack( fill=X, side = BOTTOM)

buttonquit = Button(fenetre, text = "Quitter", command = fenetre.destroy)        
buttonquit.place( x=224 , y=350 )   


##################################



##################################

#Display

fenetre.after(0,center,fenetre)
fenetre.mainloop()

Hello again ,

Even if i tried : fenetre.withdraw() it don't hide it , maybe because the second window is

interf1.mainloop()

, if i leave only "fenetre.withdraw()" it works , but if there is a page on the screen (any page) the second window come bihind that pages ...

Edited 3 Years Ago by Ismatus3

This question has already been answered. Start a new discussion instead.