The below code is a simple code which I tried to check if Tkinter worked…
JavaScript
x
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
JavaScript
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…
Advertisement
Answer
Tkinter.Tk() creates an instance of Tk() object which act as argument for mainloop. Do this instead:
JavaScript
top = Tkinter.tk() //will open a pop up box
top.mainloop()
Read this for further understanding. tkinter-understanding mainloop