I have tried to put my if statements into a messagebox function and have the button print out a message with a number and the corresponding player. I have tried everything I can think of and it still doesn't work, at the moment it prints out a random number but of course I want it to print the player's name as well, any help will be appreciated :)
print(number)
if number == 18:
print(no_18)
elif number == 17:
print(no_17)
elif number == 16:
print(no_16)
elif number == 15:
elif number == 5:
print(no_5)
elif number == 3:
print(no_3)
elif number == 2:
print(no_2)
elif number == 1:
print(no_1)
else:
print("Player not found")
def generate_number():
messagebox.showinfo("You got this player!", random.randint(1, 20))
root = tk.Tk()
canvas = tk.Canvas(root, height=600, width=600, bg="#f40000")
canvas.pack()
label1 = tk.Label(root, text="Click for a random player", bg="#f40000", fg="#323648")
label1.config(font=("", 24))
label1.place(relx=0.22, rely=0.1)
button1 = tk.Button(root, height=12, width=30, text="Random \n Man United player",
command=generate_number, bg="#ef7a85", activebackground="#dd6d11")
button1.place(relx=0.34, rely=0.4)
root.mainloop()
Aucun commentaire:
Enregistrer un commentaire