Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import random
- import time
- MASSIVE = int(21)
- class APPLICAT(Frame):
- def __init__(self, master):
- super(APPLICAT, self).__init__(master)
- self.grid()
- self.create_widgets()
- def create_widgets(self):
- self.ONELABEL = Label(self, text = "Возьмите число предметов (ЧК) от 1 до 4")
- self.ONELABEL.grid(row = 0, column = 0, sticky = W)
- self.ENT = Entry(self)
- self.ENT.grid(row = 1, column = 0, sticky = W)
- self.BUTT = Button(self, text = "Взять")
- self.BUTT.grid(row = 2, column = 0, sticky = W)
- self.BUTT2 = Button(self, text = "Начать", command = self.princip)
- self.BUTT2.grid(row = 3, column = 0, sticky = W)
- self.TEXT = Text(self, width = 40, height = 15, wrap = WORD)
- self.TEXT.grid(row = 4, column = 0, sticky = W )
- self.TEXT.insert(0.0, "Чтобы выиграть, нужно не взять последние предметы")
- self.IMAGE = PhotoImage(file = "CPAIC.gif")
- self.IMAGE2 = PhotoImage(file = "LOOSER.gif")
- self.LABEL2 = Label(self)
- self.LABEL2.grid(row = 6, column = 0, sticky = W)
- def FUNCTION(self):
- TRUE222 = True
- while TRUE222:
- if self.BUTT.bind("<ButtonPress>", self.FUNCTION):
- RESUL = int(self.ENT.get())
- if RESUL > 4 or RESUL < 1:
- self.TEXT.insert(0.0, "Введите число от 1 до 4")
- else:
- MASSIVE = MASSIVE - RESUL
- self.TEXT.insert(0.0, "Текущее число предметов: ", MASSIVE)
- break
- def princip(self):
- TRUE = True
- MASSIVE = int(21)
- self.TEXT.delete(0.0, END)
- self.TEXT.insert(0.0, "Текущее число предметов: ", str(MASSIVE))
- while TRUE:
- SOP1 = random.randint(1, 4)
- SOP2 = random.randint(1, 3)
- if MASSIVE >= 16:
- MASSIVE = MASSIVE - SOP1
- else:
- if MASSIVE <= 16 and MASSIVE >= 6:
- MASSIVE = MASSIVE - SOP2
- elif MASSIVE == 4:
- MASSIVE = MASSIVE - 4
- elif MASSIVE == 3:
- MASSIVE = MASSIVE - 2
- elif MASSIVE == 2:
- MASSIVE = MASSIVE - 1
- elif MASSIVE == 5:
- MASSIVE = MASSIVE - 4
- if MASSIVE <= 0:
- self.TEXT.delete(0.0, END)
- self.TEXT.insert(0.0, "ПОБЕДА! Вы получаете награду!")
- self.LABEL2.configure(image = self.IMAGE)
- break
- self.TEXT.delete(0.0, END)
- self.TEXT.insert(0.0, "Текущее число предметов: ", MASSIVE, "\nВаш ход")
- self.BUTT.configure(command = self.FUNCTION)
- if MASSIVE == 1:
- self.TEXT.delete(0.0, END)
- self.TEXT.insert(0.0, "ПОБЕДА! Вы получаете награду!")
- self.LABEL2.configure(image = self.IMAGE)
- break
- elif MASSIVE <= 0:
- self.TEXT.delete(0.0, END)
- self.TEXT.insert(0.0, "Вы проиграли.")
- self.LABEL2.configure(image = self.IMAGE2)
- break
- else:
- self.TEXT.delete(0.0, END)
- root = Tk()
- root.title("Игра ИБ")
- root.geometry("350x450")
- app = APPLICAT(root)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement