2023.01.12_IKT_tkinter
3
pythonProject/.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
4
pythonProject/.idea/misc.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (pythonProject) (2)" project-jdk-type="Python SDK" />
|
||||
</project>
|
8
pythonProject/.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/pythonProject.iml" filepath="$PROJECT_DIR$/.idea/pythonProject.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
10
pythonProject/.idea/pythonProject.iml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
BIN
pythonProject/kpo/ekp.jpg
Normal file
After Width: | Height: | Size: 148 KiB |
BIN
pythonProject/kpo/felh_ko.png
Normal file
After Width: | Height: | Size: 135 KiB |
BIN
pythonProject/kpo/felh_ollo.png
Normal file
After Width: | Height: | Size: 152 KiB |
BIN
pythonProject/kpo/felh_papir.png
Normal file
After Width: | Height: | Size: 137 KiB |
BIN
pythonProject/kpo/gep_ko.png
Normal file
After Width: | Height: | Size: 135 KiB |
BIN
pythonProject/kpo/gep_ollo.png
Normal file
After Width: | Height: | Size: 152 KiB |
BIN
pythonProject/kpo/gep_papir.png
Normal file
After Width: | Height: | Size: 137 KiB |
BIN
pythonProject/kpo/img.ico
Normal file
After Width: | Height: | Size: 264 KiB |
144
pythonProject/kpo/kpo.py
Normal file
|
@ -0,0 +1,144 @@
|
|||
from tkinter import *
|
||||
from PIL import Image, ImageTk
|
||||
from random import randint
|
||||
|
||||
#fő ablak
|
||||
root = Tk()
|
||||
root.title("Kő, Papír, Olló")
|
||||
root.configure(background="#9b59b6")
|
||||
window_width = 1600
|
||||
window_height = 900
|
||||
screen_width = root.winfo_screenwidth()
|
||||
screen_height = root.winfo_screenheight()
|
||||
center_x = int(screen_width / 2 - window_width / 2)
|
||||
center_y = int(screen_height / 2 - window_height / 2)
|
||||
root.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}')
|
||||
|
||||
root.columnconfigure(0, weight=3)
|
||||
root.columnconfigure(1, weight=3)
|
||||
root.columnconfigure(2, weight=3)
|
||||
root.columnconfigure(3, weight=3)
|
||||
root.columnconfigure(4, weight=3)
|
||||
|
||||
root.rowconfigure(0, weight=3)
|
||||
root.rowconfigure(1, weight=3)
|
||||
root.rowconfigure(2, weight=3)
|
||||
root.rowconfigure(3, weight=3)
|
||||
|
||||
root.state('zoomed')
|
||||
root.iconbitmap("img.ico")
|
||||
|
||||
#képek
|
||||
felh_ko_kep = ImageTk.PhotoImage(Image.open("felh_ko.png"))
|
||||
gep_ko_kep = ImageTk.PhotoImage(Image.open("gep_ko.png"))
|
||||
felh_ollo_kep = ImageTk.PhotoImage(Image.open("felh_ollo.png"))
|
||||
gep_oloo_kep = ImageTk.PhotoImage(Image.open("gep_ollo.png"))
|
||||
felh_papir_kep = ImageTk.PhotoImage(Image.open("felh_papir.png"))
|
||||
gep_papir_kep = ImageTk.PhotoImage(Image.open("gep_papir.png"))
|
||||
|
||||
#kep beszurasa
|
||||
felh_label = Label(root, image=felh_ko_kep, bg="#9b59b6")
|
||||
gep_label = Label(root, image=gep_ko_kep, bg="#9b59b6")
|
||||
gep_label.grid(row=1, column=0)
|
||||
felh_label.grid(row=1, column=4)
|
||||
|
||||
#pontok
|
||||
felhPontok = Label(root, text=0, font=("Arial", 40), bg="#9b59b6", fg="white")
|
||||
gepPontok = Label(root, text=0, font=("Arial", 40), bg="#9b59b6", fg="white")
|
||||
gepPontok.grid(row=1, column=1)
|
||||
felhPontok.grid(row=1, column=3)
|
||||
|
||||
#indikatorok
|
||||
felh_indikator = Label(root, font=("Arial", 30), text="Felhasználó", bg="#9b59b6", fg="white")
|
||||
gep_indikator = Label(root, font=("Arial", 30), text="Gép", bg="#9b59b6", fg="white")
|
||||
felh_indikator.grid(row=0, column=3)
|
||||
gep_indikator.grid(row=0, column=1)
|
||||
|
||||
#üzenetek
|
||||
msg = Label(root, font=("Arial", 26), bg="#9b59b6", fg="white")
|
||||
msg.grid(row=3, column=2, sticky="WE")
|
||||
|
||||
#update message
|
||||
def uzenetFrissitese(x):
|
||||
msg["text"] = x
|
||||
|
||||
#felhasználói pontok frissítése
|
||||
def felhasznaloiPontokFrissitese():
|
||||
pontok = int(felhPontok["text"])
|
||||
pontok += 1
|
||||
felhPontok["text"] = str(pontok)
|
||||
|
||||
#gépi pontok frissítése
|
||||
def gepiPontokFrissitese():
|
||||
pontok = int(gepPontok["text"])
|
||||
pontok += 1
|
||||
gepPontok["text"] = str(pontok)
|
||||
|
||||
#győztes kiválasztása
|
||||
def gyoztesKivalasztasa(felh, gep):
|
||||
if felh == gep:
|
||||
uzenetFrissitese("Döntetlen!")
|
||||
elif felh == "ko":
|
||||
if gep == "papir":
|
||||
uzenetFrissitese("Vesztettél!")
|
||||
gepiPontokFrissitese()
|
||||
else:
|
||||
uzenetFrissitese("Nyertél!")
|
||||
felhasznaloiPontokFrissitese()
|
||||
elif felh == "papir":
|
||||
if gep == "ollo":
|
||||
uzenetFrissitese("Vesztettél!")
|
||||
gepiPontokFrissitese()
|
||||
else:
|
||||
uzenetFrissitese("Nyertél!")
|
||||
felhasznaloiPontokFrissitese()
|
||||
elif felh == "ollo":
|
||||
if gep == "ko":
|
||||
uzenetFrissitese("Vesztettél!")
|
||||
gepiPontokFrissitese()
|
||||
else:
|
||||
uzenetFrissitese("Nyertél!")
|
||||
felhasznaloiPontokFrissitese()
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
#lehetőségek frissítése
|
||||
|
||||
lehetosegek = ["ko", "papir", "ollo"]
|
||||
|
||||
|
||||
def lehetosegekFrissitese(x):
|
||||
|
||||
# gépnek
|
||||
|
||||
gepValasztasa = lehetosegek[randint(0,2)]
|
||||
if gepValasztasa == "ko":
|
||||
gep_label.configure(image=gep_ko_kep)
|
||||
elif gepValasztasa == "papir":
|
||||
gep_label.configure(image=gep_papir_kep)
|
||||
else:
|
||||
gep_label.configure(image=gep_oloo_kep)
|
||||
|
||||
|
||||
|
||||
# felhasználónak
|
||||
|
||||
if x == "ko":
|
||||
felh_label.configure(image=felh_ko_kep)
|
||||
elif x == "papir":
|
||||
felh_label.configure(image=felh_papir_kep)
|
||||
else:
|
||||
felh_label.configure(image=felh_ollo_kep)
|
||||
gyoztesKivalasztasa(x,gepValasztasa)
|
||||
|
||||
|
||||
#gombok
|
||||
ko = Button(root, width=10, height=2, text="Kő", font=("Arial", 20), bg="#FF3E4D", fg="white", command = lambda:lehetosegekFrissitese("ko")).grid(row=2, column=1)
|
||||
papir = Button(root, width=10, height=2, text="Papír", font=("Arial", 20), bg="#FAD02E", fg="white",command = lambda:lehetosegekFrissitese("papir")).grid(row=2, column=2)
|
||||
ollo = Button(root, width=10, height=2, text="Olló", font=("Arial", 20), bg="#0ABDE3", fg="white", command = lambda:lehetosegekFrissitese("ollo")).grid(row=2, column=3)
|
||||
|
||||
|
||||
|
||||
|
||||
root.mainloop()
|