vendredi 31 juillet 2020

I am trying to display random image in GUI. But i get the error that my list is not defined, even i globalised it. Anybody knows what went wrong?

  1. def ALLFLAGS():
  2. global GERMANY
  3. global Germany
  4. Germany = ImageTk.PhotoImage(Image.open("Flags/Germany.png"))
  5. GERMANY = Label(game, image=Germany)
  6. GERMANY.photo = Germany
  7. GERMANY.pack()
  8. global FRANCE
  9. global France
  10. France = ImageTk.PhotoImage(Image.open("Flags/France.png"))
  11. FRANCE = Label(game, image=France)
  12. FRANCE.photo = France
  13. FRANCE.pack()
  14. global allflags
  15. allflags = [GERMANY, FRANCE]
  16. ...
  17. ...
  18. random.choice(allflags)

ERROR: NameError: name 'allflags' is not defined




Aucun commentaire:

Enregistrer un commentaire