Advertisement
felaris

Untitled

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