Reputation: 1001
Please help to fix the script:
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()
Once you load a child window shows "child". My idea for this child window should appear after the user clicks on the button "add record".
Upvotes: 0
Views: 178
Reputation: 2882
While creating the button, do not call the callback function. Change to this:
tool3=tkinter.Button(tollbarFrame, text='Add record', command=self.add_record)
Upvotes: 1