Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # emoji game
- from guizero import App, Text, Box, Picture, PushButton
- import os
- from random import shuffle
- # initialisations
- xrange=4
- yrange=4
- # 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))]
- # the above will pull in any file name e.g. thumbsnail so needs to be filtered. will not happen often with 1000 files
- # shuffle the emojis
- shuffle(emojis)
- app = App("emoji match")
- # create a box to house the grid
- pictures_box = Box(app, layout="grid")
- # create list for picture
- pictures = []
- for x in range(0,xrange):
- for y in range(0,yrange):
- # put the pictures into the list
- picture = Picture(pictures_box, grid=[x,y])
- pictures.append(picture)
- i = 0
- for picture in pictures:
- picture.image = emojis[i]
- i = i + 1
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement