commit 59d0e218c8585d125f3edaad7af51a762b62e31a Author: medvegergo Date: Thu Jan 12 23:03:48 2023 +0100 2023.01.12_IKT_tkinter diff --git a/pythonProject/.idea/.gitignore b/pythonProject/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/pythonProject/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/pythonProject/.idea/inspectionProfiles/profiles_settings.xml b/pythonProject/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/pythonProject/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/pythonProject/.idea/misc.xml b/pythonProject/.idea/misc.xml new file mode 100644 index 0000000..ec5ae5d --- /dev/null +++ b/pythonProject/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/pythonProject/.idea/modules.xml b/pythonProject/.idea/modules.xml new file mode 100644 index 0000000..e15ec35 --- /dev/null +++ b/pythonProject/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pythonProject/.idea/pythonProject.iml b/pythonProject/.idea/pythonProject.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/pythonProject/.idea/pythonProject.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/pythonProject/kpo/ekp.jpg b/pythonProject/kpo/ekp.jpg new file mode 100644 index 0000000..5b22f44 Binary files /dev/null and b/pythonProject/kpo/ekp.jpg differ diff --git a/pythonProject/kpo/felh_ko.png b/pythonProject/kpo/felh_ko.png new file mode 100644 index 0000000..a8645fe Binary files /dev/null and b/pythonProject/kpo/felh_ko.png differ diff --git a/pythonProject/kpo/felh_ollo.png b/pythonProject/kpo/felh_ollo.png new file mode 100644 index 0000000..3ee1d77 Binary files /dev/null and b/pythonProject/kpo/felh_ollo.png differ diff --git a/pythonProject/kpo/felh_papir.png b/pythonProject/kpo/felh_papir.png new file mode 100644 index 0000000..ba33cee Binary files /dev/null and b/pythonProject/kpo/felh_papir.png differ diff --git a/pythonProject/kpo/gep_ko.png b/pythonProject/kpo/gep_ko.png new file mode 100644 index 0000000..c1b9a53 Binary files /dev/null and b/pythonProject/kpo/gep_ko.png differ diff --git a/pythonProject/kpo/gep_ollo.png b/pythonProject/kpo/gep_ollo.png new file mode 100644 index 0000000..f2d6565 Binary files /dev/null and b/pythonProject/kpo/gep_ollo.png differ diff --git a/pythonProject/kpo/gep_papir.png b/pythonProject/kpo/gep_papir.png new file mode 100644 index 0000000..feae820 Binary files /dev/null and b/pythonProject/kpo/gep_papir.png differ diff --git a/pythonProject/kpo/img.ico b/pythonProject/kpo/img.ico new file mode 100644 index 0000000..6c4653b Binary files /dev/null and b/pythonProject/kpo/img.ico differ diff --git a/pythonProject/kpo/kpo.py b/pythonProject/kpo/kpo.py new file mode 100644 index 0000000..1233093 --- /dev/null +++ b/pythonProject/kpo/kpo.py @@ -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()