2016-09-17 195 views
0

我想在我的小部件中創建一個按鈕,當我按下它時,它會繼續下一行代碼,並關閉按鈕所在的現有小部件。如何製作繼續按鈕? 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

您還沒有任何代碼?你究竟在爲什麼而掙扎? – galah92

+1

這只是GUI編程的工作原理。您應該閱讀關於基於事件的編程的教程。在你的情況下,通常你會創建一個調用'save'的「保存」按鈕。 –

+0

然而,是否有可能做出繼續按鈕 – user6842389

回答

0

對不起,這個遲到的答案。要創建一個'繼續'按鈕:

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) 

然後你必須編寫函數'func'來滿足你的需求。

希望這可以幫助