python - 尝试在 Python 中关闭 Tkinter 窗口时发生 TypeError
问题描述
我目前正在为学校做一个课程项目,它是一个具有使用 Tkinter、Python 和 SQLite3 的用户界面的数据库系统。我使用此功能关闭窗口,但显示以下错误。我附上了一段代码和一张表格的照片。
Tkinter 回调 Traceback 中的异常(最近一次调用最后一次):文件“C:\Users\Ryan\AppData\Local\Programs\Python\Python38-32\lib\tkinter_ init _.py”,第 1883 行,调用 返回 self。 func(*args) TypeError: quit() 接受 0 个位置参数,但给出了 1 个
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()
解决方案
基本类错误。所有方法都必须将“self”作为第一个参数。
class CustomerForm:
def quit(self):
root.quit()
推荐阅读
- php - 用户没有正确的角色。Laravel 权限
- r - 如何在r中提取子字符串
- asp.net - asp.net Core 2 中的 RenderPartialToString 怎么做?
- c++ - 英特尔 Vtune 放大器 2018 更新 2 结果数据库未创建
- apache-superset - 超集中无法进行查询缓存
- c# - Aruco DetectMarkers 实现 Emgu C#
- c++ - OpenGL 相机方向
- r - 非最小二乘的初始值适合 R
- python - 我不断收到命令“python setup.py egg_info”失败,错误代码为 1
- typescript - 如何为仅在 TypeScript 中导出的模块定义名称