Search code examples
pythonpython-2.7tkintersuper

How to use super() when subclassing Tkinter widgets?


Trying to create Tkinter window using super(). I get this error:

TypeError: super() argument 1 must be type, not classobj

Code:

import Tkinter as tk

class Application(tk.Frame):

    def __init__(self, master):
        super(Application, self).__init__(master)
        self.grid()


def main():
    root = tk.Tk()
    root.geometry('200x150')
    app = Application(root)

    root.mainloop()

main()

Solution

  • Tkinter uses old-style classes. super() can only be used with new-style classes.