Tushar
Tushar

Reputation: 57

unbound method mainloop() must be called with Tk instance as first argument (got nothing instead)

The below code is a simple code which I tried to check if Tkinter worked...

import Tkinter
top=Tkinter.Tk
top.mainloop()

Acoording to https://www.tutorialspoint.com/python/python_gui_programming.html

this should open a blank window

But the following error message was received

  File "b.py", line 3, in <module>
    top.mainloop()
TypeError: unbound method mainloop() must be called with Tk instance as first argument (got nothing instead)

Any suggestions...

Upvotes: 0

Views: 409

Answers (1)

Anubhav Singh
Anubhav Singh

Reputation: 482

Tkinter.Tk() creates an instance of Tk() object which act as argument for mainloop. Do this instead:

top = Tkinter.tk() //will open a pop up box
top.mainloop()

Read this for further understanding. tkinter-understanding mainloop

Upvotes: 1

Related Questions