【发布时间】:2015-03-19 20:32:10
【问题描述】:
我正在尝试从另一个名为 Edit_user_admin 的函数中调用一个名为 Add_user 的函数,我很确定我已经正确编写了所有内容,但我一直收到同样的错误。
File "G:/PVH_work/PVH_program/ParkTheReal.py", line 395, in <lambda>
Add_user = ttk.Button(frame_27, text="Add User", command=lambda: Add_user(frame_27, data_dictionary)).grid(row=1, column=0)
TypeError: 'NoneType' object is not callable
这里是函数Edit_user_admin:
def Edit_user_admin(form_item, data_dictionary, row_num):
form_item.grid_forget()
frame_27 = Frame(gui)
frame_27.grid()
MyProfile = ttk.Button(frame_27, text="My profile", command=lambda: My_profile_admin(frame_27, data_dictionary, row_num)).grid(row=0, column=0)
TrainingRecord = ttk.Button(frame_27, text="Training Record", command=lambda: Training_record_admin(frame_27, data_dictionary, row_num)).grid(row=0, column=1)
Compare = ttk.Button(frame_27, text="Compare", command=lambda: Compare_admin(frame_27, data_dictionary, row_num)).grid(row=0, column=2)
EditUsers = ttk.Button(frame_27, text="Edit Users", command=lambda: Edit_user_admin(frame_27, data_dictionary, row_num)).grid(row=0, column=3)
Team = ttk.Button(frame_27, text="View/Edit Team", command=lambda: Team_admin(frame_27, data_dictionary, row_num)).grid(row=0, column=4)
Logout = ttk.Button(frame_27, text="Logout", command=lambda: Logout(frame_27)).grid(row=0, column=5)
Add_user = ttk.Button(frame_27, text="Add User", command=lambda: Add_user(frame_27, data_dictionary, row_num)).grid(row=1, column=0)
Edit_user = ttk.Button(frame_27, text="Edit User", command=lambda: Edit_user(frame_27, data_dictionary, row_num)).grid(row=1, column=1)
Remove_user = ttk.Button(frame_27, text="Remove User", command=lambda: Remove_user(frame_27, data_dictionary, row_num)).grid(row=1, column=2)
这里是函数Add_user:
def Add_user(form_item, data_dictionary, row_num):
form_item.grid_forget()
frame_28 = Frame(gui)
frame_28.grid()
#Declare variables for creating a new user account
__Username = StringVar()
__Name = StringVar()
__Age = StringVar()
__Email = StringVar()
__DoB = StringVar()
MyProfile = ttk.Button(frame_28, text="My profile", command=lambda: My_profile_admin(frame_28, data_dictionary, row_num)).grid(row=0, column=0)
TrainingRecord = ttk.Button(frame_28, text="Training Record", command=lambda: Training_record_admin(frame_28, data_dictionary, row_num)).grid(row=0, column=1)
Compare = ttk.Button(frame_28, text="Compare", command=lambda: Compare_admin(frame_28, data_dictionary, row_num)).grid(row=0, column=2)
EditUsers = ttk.Button(frame_28, text="Edit Users", command=lambda: Edit_user_admin(frame_28, data_dictionary, row_num)).grid(row=0, column=3)
Team = ttk.Button(frame_28, text="View/Edit Team", command=lambda: Team_admin(frame_28, data_dictionary, row_num)).grid(row=0, column=4)
Logout = ttk.Button(frame_28, text="Logout", command=lambda: Logout_so(frame_28)).grid(row=0, column=5)
我在其他函数上遇到过这个错误,但我发现在我尝试调用的函数名称中添加一个“_”,然后在命令中添加相同的扩展名是有效的。
【问题讨论】: