Python Closing Toplevel Window Error -


i wanted code create popup error window destroys after 4 seconds can closed via button.

def error(self):     top = toplevel()     top.after(4000, lambda: top.destroy())     center_window(300,100, top)     top.title("error")     label(top, text="please enter valid code", height=3, width=200).pack()     ok = button(top, text="ok", command=top.destroy)     ok.pack()     ok.bind("<return>", lambda a: top.destroy())     ok.focus_set() 

i have run code , works fine 90% of time except throws error:

 typeerror: <lambda>() takes 1 argument (0 given) 

i have done research says tkinters threading. not sure if issue when take out line of code:

top.after(4000, lambda: top.destroy()) 

it seems work. if me, have taught myself know of python, sure there holes in learning. think may need somehow use main thread of execution destroy window, or otherwise create own custom widget. appreciated.

when using after or bind, don't need use lambda. instead, example, use:

top.after(4000, top.destroy) 

which references function top.destroy directly.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -