Feb-08-2020, 06:20 PM
(This post was last modified: Feb-08-2020, 06:21 PM by Gribouillis.)
In this forum, users live in many different places around the world, but everybody agrees on the use of english as a common language, so please try to write your future posts in english. I know it can be difficult but there are online translation tools that can help you with this.
Concerning the code, usually one uses a single
Concerning the code, usually one uses a single
Tk
instance at a time in tkinter, so if you want to create several toplevel windows, use instances of the Toplevel
class instead. Also mainloop()
is normally called on a single window. I changed a few things in the code to make it work.from tkinter import * def louer_materiel(): def louer(): valeur=saisir.get() print(str(valeur)) fenetre1.destroy() fenetre1 = Toplevel() saisir=StringVar() entree = Entry(fenetre1,textvariable=saisir, width=30).grid(row=2, column=2,columnspan=2,pady=8) bouton_valider = Button(fenetre1, text="ok", command=louer,width=10,heigh=1).grid(row=3,column=2,padx=20, pady=8) def acceuil (): fenetre = Tk() bouton1 = Button(fenetre, text="Louer un matériel",width=36,heigh=1,command=louer_materiel).grid(row=2,column=1,padx=20, pady=8) fenetre.mainloop() acceuil()