Home > Back-end >  Python - Having some troubles with the super function and importing
Python - Having some troubles with the super function and importing

Time:06-30

I have been trying to transition to Python recently but my brain isn't working well with it.

I really can't find what is the problem.

window.py

import tkinter as tk

class Window(tk.Tk):
    def __init__(self):
        super(Window, self).__init__()

main.py

from window import Window

win = Window()
win.mainloop()

Error message:

File "main.py", line 3, in <module>
    win = Window()
  File "window.py", line 5, in __init__
    super(Window, self).__init__()
TypeError: super() argument 1 must be type, not classobj

Am I just being dumb?

Thank you.

CodePudding user response:

If you are using a recent python version super itself needs no arguments:

class Window(tk.Tk):
    def __init__(self):
        super().__init__()

CodePudding user response:

I am so sorry everybody ran the file with python 2.

Just typed "python3 main.py" rather than "python main.py"

  • Related