0
請幫忙修復腳本:單擊按鈕後如何獲取子窗口?
import tkinter
class Application(tkinter.Frame):
def __init__(self, parent):
tkinter.Frame.__init__(self, parent, bg='yellow')
self.pack(side = 'top', fill = 'x')
self.make_elements()
def make_elements(self):
tollbarFrame=tkinter.Frame(self)
tollbarFrame.pack(side='top', fill='x')
tool3=tkinter.Button(tollbarFrame, text='Add record', command=self.add_record())
tool3.pack(side='left')
contentFrame=tkinter.Frame(self)
contentFrame.pack(side='top', fill='x')
butt = tkinter.Button(contentFrame, text='qwerer')
butt.pack()
def add_record(self):
child = tkinter.Toplevel()
bu = tkinter.Button(child, text='sdfsf')
bu.pack()
if __name__ == '__main__':
root = tkinter.Tk()
root.title('dvd list')
root.geometry('700x500')
Application(root)
root.mainloop()
當你將一個子窗口顯示「孩子」。當用戶點擊按鈕「添加記錄」後,我的想法應該出現在這個子窗口中。