I am currently working on a coursework project for school and it is a database system with a user interface using Tkinter, Python and SQLite3.I made this function to close the window, however the following error is being displayed. I have attached a snippet of the code and a photo of the form.
Exception in Tkinter callback Traceback (most recent call last): File “C:UsersRyanAppDataLocalProgramsPythonPython38-32libtkinter_init_.py”, line 1883, in call return self.func(*args) TypeError: quit() takes 0 positional arguments but 1 was given
import sys try: import Tkinter as tk except ImportError: import tkinter as tk try: import ttk py3 = False except ImportError: import tkinter.ttk as ttk py3 = True from PIL import Image, ImageTk import CustomerForm_support import os.path import sqlite3 import tkinter.messagebox def vp_start_gui(): '''Starting point when module is the main routine.''' global val, w, root global prog_location prog_call = sys.argv[0] prog_location = os.path.split(prog_call)[0] root = tk.Tk() top = CustomerForm (root) CustomerForm_support.init(root, top) root.mainloop() w = None def create_CustomerForm(rt, *args, **kwargs): '''Starting point when module is imported by another module. Correct form of call: 'create_CustomerForm(root, *args, **kwargs)' .''' global w, w_win, root global prog_location prog_call = sys.argv[0] prog_location = os.path.split(prog_call)[0] #rt = root root = rt w = tk.Toplevel (root) top = CustomerForm (w) CustomerForm_support.init(w, top, *args, **kwargs) return (w, top) class CustomerForm: def quit(): root.quit()
Advertisement
Answer
Basic class mistake. All methods must have ‘self’ as the first argument.
class CustomerForm: def quit(self): root.quit()