maroph

emojis_sel16.py

Dec 13th, 2019
373
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.  
  6. # set the path to the emoji folder on your computer
  7. emojis_dir = "emojis"
  8.  
  9. # create a list of the locations of the emoji images
  10. emojis = [os.path.join(emojis_dir, f) for f in os.listdir(emojis_dir) if os.path.isfile(os.path.join(emojis_dir, f))]
  11.  
  12. # shuffle the emojis
  13. shuffle(emojis)
  14.  
  15. app = App("emoji match")
  16.  
  17. # create a box to house the grid
  18. pictures_box = Box(app, layout="grid", border=True)
  19.  
  20. # create an empty list to which pictures will be added
  21. pictures = []
  22. for x in range(0,4):
  23.     for y in range(0,4):
  24.         # put the pictures into the list
  25.         picture = Picture(pictures_box, grid=[x,y])
  26.         pictures.append(picture)
  27.  
  28. idx = -1
  29. for picture in pictures:
  30.     # make the picture a random emoji
  31.     picture.image = emojis[idx]
  32.     idx = idx - 1
  33.  
  34. app.display()
Advertisement
Add Comment
Please, Sign In to add comment