maroph icon

emojis_sel16.py

maroph | PRO | 12/13/19 02:50:03 PM UTC | 0 ⭐ | 428 👁️ | Never ⏰ | []
Python |

870 B

|

None

|

0 👍

/

0 👎

import os
from random import shuffle
from guizero import App, Box, Picture
 
 
# set the path to the emoji folder on your computer
emojis_dir = "emojis"
 
# create a list of the locations of the emoji images
emojis = [os.path.join(emojis_dir, f) for f in os.listdir(emojis_dir) if os.path.isfile(os.path.join(emojis_dir, f))]
 
# shuffle the emojis
shuffle(emojis)
 
app = App("emoji match")
 
# create a box to house the grid
pictures_box = Box(app, layout="grid", border=True)
 
# create an empty list to which pictures will be added
pictures = []
for x in range(0,4):
    for y in range(0,4):
        # put the pictures into the list
        picture = Picture(pictures_box, grid=[x,y])
        pictures.append(picture)
 
idx = -1
for picture in pictures:
    # make the picture a random emoji
    picture.image = emojis[idx]
    idx = idx - 1
 
app.display()

Comments