-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
65 lines (60 loc) · 1.82 KB
/
main.py
File metadata and controls
65 lines (60 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from tkinter import *
from random import randint
from PIL import Image, ImageTk
import pygame, sys, os
global imageshown
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
pygame.mixer.init()
root=Tk()
'''try:
root.state('zoomed')
except:
root.attributes('-zoomed', True)'''
root.title("Load Cheese")
root.geometry("600x500")
try:
root.iconbitmap(resource_path("images/cheese.ico"))
except:
try:
root.iconbitmap(resource_path("images/cheese.xbm"))
except:
print("Error loading icon")
imageshown=False
def show_cheese():
global imageshown
r=randint(1,34)
if r == 34:
r=randint(1,34)
if r==34:
print("Imposter")
if imageshown==True:
root.img.destroy()
render=ImageTk.PhotoImage(Image.open(resource_path(f"images/potato.png")))
root.img=Label(root, image=render)
root.img.image=render
#img.place(x=10,y =10)
root.img.pack()
imageshown=True
pygame.mixer.music.load(resource_path(f"sounds/imposter.mp3"))
else:
print(r)
if imageshown==True:
root.img.destroy()
render=ImageTk.PhotoImage(Image.open(resource_path(f"images/cheese{r}.png")))
root.img=Label(root, image=render)
root.img.image=render
#img.place(x=10,y =10)
root.img.pack()
imageshown=True
pygame.mixer.music.load(resource_path(f"sounds/cheese{r}.mp3"))
pygame.mixer.music.play()
button=Button(root, text="We like cheese", command=show_cheese)
button.pack()
root.mainloop()