I am getting multiple errors and all in Tkinter basically. I am a newbie in this and have no clues what are these errors. Hence i started on reading on Tkinter first. The error messages starts with “Exception in Tkinter call-back” and pops so many errors which i do not know about. What is Tkinter function? How to use that function? How to avoid errors in Tkinter function? I am creating a project for learning colours for children using python. Thank you for your great help.
How to resolve Tkinter errors in Python
The Tkinter module is the short term for “Tk interface”. It is a standard Python interface to the Tk GUI toolkit. Both Tkinter and Tk are accessible on the majority of UNIX platforms including Microsoft Windows systems. In Python 3, Tkinter has been renamed to tkinter. Tkinter was written by Fredrik Lundh. See the example below.
from Tkinter import *
class Application(Frame):
def say_hi(self):
print "hi there, everyone!"
def createWidgets(self):
self.QUIT = Button(self)
self.QUIT["text"] = "QUIT"
self.QUIT["fg"] = "red"
self.QUIT["command"] = self.quit
self.QUIT.pack({"side": "left"})
self.hi_there = Button(self)
self.hi_there["text"] = "Hello",
self.hi_there["command"] = self.say_hi
self.hi_there.pack({"side": "left"})
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()
The above example is a simple hello world program. It will display the message “hi there, everyone!”