Ask coding questions

← Back to all posts
How would I do this?
MaciahLawson (32)

How do I make a link so people can play my game on full screen? I have posted a game on share btw.

Answered by TheBest156 (43) [earned 5 cycles]
View Answer
Comments
hotnewtop
TheBest156 (43)

from tkinter import *
from PIL import Image, ImageTk

def showPIL(pilImage):
root = Tk()
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.overrideredirect(1)
root.geometry("%dx%d+0+0" % (w, h))
root.focus_set()
root.bind("<Escape>", lambda e: (e.widget.withdraw(), e.widget.destroy()))
canvas = Canvas(root, width=w, height=h)
canvas.pack()
canvas.configure(background='black')
imgWidth, imgHeight = pilImage.size
if imgWidth > w or imgHeight > h:
ratio = min(w / imgWidth, h / imgHeight)
imgWidth = int(imgWidth ratio)
imgHeight = int(imgHeight
ratio)
pilImage = pilImage.resize((imgWidth, imgHeight), Image.ANTIALIAS)
image = ImageTk.PhotoImage(pilImage)
imagesprite = canvas.create_image(w / 2, h / 2, image=image)
root.mainloop()

img1 = Image.open("img1.png")
img2 = Image.open('img2.png')

while True:
n = int(input('Numero: '))
if n == 1:
showPIL(img1)
continue
elif n == 2:
showPIL(img2)
continue
else:
break