Why is my Frame subclass throwing an error in init?
You need to unpack kw
in the call to Frame.__init__
.
This should work for you.
from Tkinter import *class TFrame(Frame): def __init__(self, master=None, cnf={}, **kw): Frame.__init__(self, master, cnf, **kw)if __name__ == '__main__': root = Tk() tf = TFrame(root) tf.pack() root.mainloop()
The issue is that Frame
is using **kw
in its call signature, which expects a variable amount of keyword arguments, but you're trying to pass a dictionary as a positional argument.