Advertisement
Mori007

emoMatch

Feb 11th, 2021
812
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. import os
  2. from random import shuffle
  3. from guizero import App, Box, Picture
  4.  
  5. # set the path to the emoji folder on your computer
  6. emojis_dir = "d:\WS_guizero\Ftrguizero\emojis"
  7. # create a list of the locations of the emoji images
  8. emojis = [os.path.join(emojis_dir, f) for f in os.listdir(emojis_dir) if os.path.isfile(os.path.join(emojis_dir, f))]
  9. # shuffle the emojis
  10. shuffle(emojis)
  11.  
  12. app = App("Emoji Match")
  13. # create a box to house the grid
  14. pictures_box = Box(app,layout="grid")
  15.  
  16. # create an empty list to which pictures will be added
  17. pictures = []
  18. for x in range(0,4):
  19.     for y in range(0,4):
  20.         # put the pictures into the list
  21.         picture = Picture(pictures_box, grid=[x,y])
  22.         pictures.append(picture)
  23.  
  24. # for each picture in the list
  25. for picture in pictures:
  26.     # make the picture a random emoji
  27.     picture.image = emojis.pop()
  28.  
  29. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement