import tkinter as tk
window = tk.Tk()
window.title("Player number,rating, and name")
window.minsize(800,800)
lastname = ["Fook", "Bill", "Nine",
"Chen","Ashley","Noon",'Zen','Naphut',"Cole",'Takeru']
player_number = [1,41,33,3,2,4,5,6,7,8]
rating = [10,1,4,5,6,8,3,4,10,10]
question = tk.Label(master=window, text=
"Type 1, for player's name and rating \nType 2, for players who score 9 or 10"
+ "\nType 3, for players who score 1"
)
question.pack()
input_Box = tk.Entry(master=window)
input_Box.pack()
def menu():
input_Box_get = int(input_Box.get())
if input_Box_get == 1:
def menu1():
number_input_get = int(number_input.get())
show = ''
for i in range(len(player_number)):
if number_input_get == (player_number[i]):
show += lastname[i] + ' : ' + rating[i]
output2.configure(text=show)
player_number = tk.Label(master=window,text='Input player number here in the box:')
player_number.pack()
number_input = tk.Entry(master=window)
number_input.pack()
Button2 = tk.Button(master=window,text='Enter',command=menu1)
Button2.pack()
output2 = tk.Label(master=window)
output2.pack()
if input_Box_get == 2:
show = ''
for i in range(len(rating)):
if rating[i] == 9 or rating[i] == 10:
show += lastname[i] + ','
output.configure(text=show)
if input_Box_get == 3:
show = ''
for i in range(len(rating)):
if rating[i] == 1:
show += lastname[i] + ','
output.configure(text=show)
Button1 = tk.Button(master=window, text="Enter", command=menu)
Button1.pack()
output = tk.Label(master=window)
output.pack()
window.mainloop()
The output of this code shown in the terminal of Vscode is:
'Label' has no length()
The def menu1() does not work and it does not show in the tkinter GUI. Maybe the issue is the def function inside the def function which might not be correct. How can I fix this issue?