How to resolve Tkinter errors in Python

Asked By 10 points N/A Posted on -

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.

Answered By 590495 points N/A #194217

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)

root = Tk()
app = Application(master=root)

The above example is a simple hello world program. It will display the message “hi there, everyone!”

Login/Register to Answer

Related Questions