Getting error: TypeError: module() takes at most 2 arguments (3 given)

Question:

I started learning the MVC pattern and started writing code according to this pattern but I don’t understand what is my mistake. When I try to run the program it shows me:

line 143, in <module>
    class App(tkinter):
TypeError: module() takes at most 2 arguments (3 given)

I will attach below the whole code:

import tkinter
from tkinter import *
from tkinter import filedialog as fd
import os
from os.path import basename
from zipfile import ZipFile
import string
import crypt


class Model:
    def __init__(self):
        pass

    @staticmethod
    def key_get(num):
        with open(num, 'r') as file:
            lines = file.read()
            return lines


class View(tkinter.Frame):
    def __init__(self):
        super().__init__()

        # text top
        self.color_text_top = Label(self, bg='blue', height=3)
        self.color_text_top.pack(fill=X)

        self.text_top = Label(text='MS4Bike Update Generator', fg='white', bg='blue', font='Arial 12')
        self.text_top.place(height=40, x=15, y=4)

        # version string
        self.label0 = tkinter.Label(text="Version", bg="#AEC09A", font=('Arial', 10, 'bold'))
        self.label0.place(x=25, y=70)

        # enter programme version
        def validate(new_value):
            return all(c in string.digits or c == '.' for c in new_value)

        self.vcmd = (self.register(validate), '%P')
        self.ent = Entry(self, validate='key', validatecommand=self.vcmd, width=20, bd=3)
        self.ent.pack()
        self.ent.place(x=25, y=90)

        # first name
        self.label1 = tkinter.Label(self, text="Programmodner auswählen(ms4bikeHost)", bg="#AEC09A",
                                    font=('Arial', 10, 'bold'))
        self.label1.place(x=25, y=125)

        # second name
        self.label2 = tkinter.Label(text="Speicherort für Update-Datei auswählen", bg="#AEC09A",
                                    font=('Arial', 10, 'bold'))
        self.label2.place(x=25, y=250)

        # third name
        self.label3 = tkinter.Label(text="Schlüsseldatel auswählen", bg="#AEC09A", font=('Arial', 10, 'bold'))
        self.label3.place(x=25, y=375)

        # first button
        self.open_button1 = Button(self, bd=0, relief=GROOVE, text='Ändern', bg="#c0cfaf", width=20, height=2,
                                   command=self.controller.open_text_file1)
        self.open_button1.place(x=600, y=147)

        # second button
        self.open_button2 = Button(self, bd=0, relief=GROOVE, text='Ändern', bg="#c0cfaf", width=20, height=2,
                                   command=self.controller.open_text_file2)
        self.open_button2.place(x=600, y=272)

        # third button
        self.open_button3 = Button(self, bd=0, relief=GROOVE, text='Ändern', bg="#c0cfaf", width=20, height=2,
                                   command=self.controller.open_text_file3)
        self.open_button3.place(x=600, y=397)

        # fourth button
        self.open_button4 = Button(self, bd=0, relief=GROOVE, text='Update erstellen', bg="#c0cfaf", width=93, height=3,
                                   font=('Arial', 10, 'bold'),
                                   command=lambda: self.controller.generate_update(self.ent.get()))
        self.open_button4.place(x=20, y=490)

        # white input fields
        self.text_first = Text(self, font='Arial 14', highlightthickness=1, highlightcolor='black',
                               highlightbackground='black')
        self.text_first.place(x=20, y=150, height=33, width=520)

        self.text_second = Text(self, font='Arial 14', highlightthickness=1, highlightcolor='black',
                                highlightbackground='black')
        self.text_second.place(x=20, y=275, height=33, width=520)

        self.text_third = Text(self, font='Arial 14', highlightthickness=1, highlightcolor='black',
                               highlightbackground='black')
        self.text_third.place(x=20, y=400, height=33, width=520)

        self.controller = None

    def set_controller(self, controller):
        self.controller = controller


class Controller:
    def __init__(self, model, view):
        self.model = model
        self.view = view

    def open_text_file1(self):
        f = fd.askdirectory()
        self.view.text_first.insert('1.0', f)

    def open_text_file2(self):
        f = fd.askdirectory()
        self.view.text_second.insert('1.0', f)

    def open_text_file3(self):
        filetypes = (
            ('text files', '*.txt'),
            ('All files', '*.*')
        )
        f = fd.askopenfilename(filetypes=filetypes)
        self.view.text_third.insert('1.0', f)

    def generate_update(self, version):
        key = self.model.key_get(self.view.text_third.get('1.0', 'end-1c'))
        source = self.view.text_first.get('1.0', 'end-1c')
        destination = self.view.text_second.get('1.0', 'end-1c')
        self.model.key = key.encode('ascii')
        zip_path = destination + f"\update_{version}.zip"
        enu_path = destination + f"\update_{version}.enu"

        with ZipFile(zip_path, 'w') as zip:
            for folder, subfolders, filenames in os.walk(source):
                for filename in filenames:
                    if not basename(folder) in IGNORE and not basename(filename) in IGNORE:
                        filepath = os.path.join(folder, filename)
                        filepath_zip = os.path.relpath(filepath, source)
                        zip.write(filepath, filepath_zip)
        crypt.encrypt_file(key, zip_path, enu_path)


CONFIG_FILE = 'config.ini'
IGNORE = {'.vscode', '__pycache__'}


class App(tkinter):
    def __init__(self):
        self.geometry('800x580')
        self.geometry('+200+100')
        self.resizable(width=False, height=False)
        self.configure(bg='#AEC09A')
        self.title("MS4Bike")

        model = Model()
        view = View()
        controller = Controller(model, view)
        view.set_controller(controller)


if __name__ == '__main__':
    app = App()
    app.mainloop()

Asked By: nothin7

||

Answers:

I do not used import zipFilele import crypt. Actually, you are missing something parameter in app = App().

class App():
    def __init__(self, tkinter):
        tkinter.geometry('800x580')
         
        tkinter.resizable(width=False, height=False)
        tkinter.configure(bg='#AEC09A')
        tkinter.title("MS4Bike")

        model = Model()
        view = View()
        controller = Controller(model, view)
        view.set_controller(controller)


if __name__ == '__main__':
    root = tkinter.Tk()
    app = App(root)
    app.mainloop()

Result:

enter image description here

Answered By: toyota Supra