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
JavaScript
x
52
52
1
import sys
2
3
try:
4
import Tkinter as tk
5
except ImportError:
6
import tkinter as tk
7
8
try:
9
import ttk
10
py3 = False
11
except ImportError:
12
import tkinter.ttk as ttk
13
py3 = True
14
15
from PIL import Image, ImageTk
16
17
import CustomerForm_support
18
import os.path
19
import sqlite3
20
import tkinter.messagebox
21
22
def vp_start_gui():
23
'''Starting point when module is the main routine.'''
24
global val, w, root
25
global prog_location
26
prog_call = sys.argv[0]
27
prog_location = os.path.split(prog_call)[0]
28
root = tk.Tk()
29
top = CustomerForm (root)
30
CustomerForm_support.init(root, top)
31
root.mainloop()
32
33
w = None
34
def create_CustomerForm(rt, *args, **kwargs):
35
'''Starting point when module is imported by another module.
36
Correct form of call: 'create_CustomerForm(root, *args, **kwargs)' .'''
37
global w, w_win, root
38
global prog_location
39
prog_call = sys.argv[0]
40
prog_location = os.path.split(prog_call)[0]
41
#rt = root
42
root = rt
43
w = tk.Toplevel (root)
44
top = CustomerForm (w)
45
CustomerForm_support.init(w, top, *args, **kwargs)
46
return (w, top)
47
48
49
class CustomerForm:
50
def quit():
51
root.quit()
52
Advertisement
Answer
Basic class mistake. All methods must have ‘self’ as the first argument.
JavaScript
1
4
1
class CustomerForm:
2
def quit(self):
3
root.quit()
4