2016-09-17 1 views
0

Je veux faire un bouton dans mon widget que lorsque je l'appuie, il passe aux lignes de code suivantes, et ferme le widget existant de l'endroit où se trouve le bouton.Comment créer un bouton continuer? Python, tkinter

from tkinter import * 

root = Tk() 
Label(root, text = "Childs First name").grid(row = 0, sticky = W) 
Label(root, text = "Childs Surname").grid(row = 1, sticky = W) 
Label(root, text = "Childs Year of Birth").grid(row = 2, sticky = W) 
Label(root, text = "Childs Month of Birth").grid(row = 3, sticky = W) 
Label(root, text = "Childs Day of Birth").grid(row = 4, sticky = W) 

Fname = Entry(root) 
Sname = Entry(root) 
x = Entry(root) 
y = Entry(root) 
z = Entry(root) 


Fname.grid(row = 0, column = 1) 
Sname.grid(row = 1, column = 1) 
x.grid(row = 3, column = 1) 
y.grid(row = 2, column = 1) 
z.grid(row = 4, column = 1) 

button1 = Button(root, text = "Quit", command = root.quit, bg = "Grey", fg =  "White", width = 12).grid(row = 5, column = 0, sticky = W) 


def save(): 
Fname_value = Fname.get() 
Sname_value = Sname.get() 
x_value = x.get() 
y_value = y.get() 
z_value = z.get() 

save() 
mainloop() 
+0

Avez-vous un code encore? Avec quoi vous battez-vous exactement? – galah92

+1

Ce n'est pas comme ça que la programmation GUI fonctionne. Vous devriez probablement lire un tutoriel sur la programmation basée sur les événements. Dans votre cas, vous devez généralement créer un bouton "Enregistrer" qui appelle "Enregistrer". –

+0

Cependant, est-il possible de faire un bouton continuer – user6842389

Répondre

0

Désolé pour cette réponse tardive. Pour créer un bouton "continuer":

continue_button = tk.Button(frame,text='continue',command=func) 
continue_button.config(width=width_continue_button) 
# set the coordinates as you want. here 2,6 for the example 
continue_button.grid(row=2,column=6,padx=width_continue_grid) 

Ensuite, vous devez écrire la fonction 'func' pour répondre à vos besoins.

espère que cela aide