from tkinter import *
import random
win=Tk()
win.title('КНБ')
win.geometry('500x500')
player=''
player_points=0
bot_points=0
def bot_hod():
global player,player_points,bot_points
command=['камень','ножницы','бумага']
bot = random.choice(command)
hod_bota['text']=f'Бот походил - {bot}'
if player == bot:
result['text']='ничья!'
elif player == 'камень' and bot == 'ножницы' or player == 'ножницы' and bot == 'бумага' or player == 'бумага' and bot == 'камень':
result['text']='ты победил'
player_points += 1
elif player == 'камень' and bot == 'бумага' or player == 'ножницы' and bot == 'камень' or player == 'бумага' and bot == 'ножницы':
result['text']='ты проиграл'
bot_points += 1
score['text']=f'{player_points} VS {bot_points}'
if player_points==10 or bot_points==10:
kamen.destroy()
sc.destroy()
pa.destroy()
hod_bota.destroy()
if player_points==10 :
result['text'] = 'ты победил'
if bot_points==10:
result['text'] = 'ты проиграл'
def kamen_hod():
global player
player='камень'
bot_hod()
kamen=Button(text='камень', width='20', height=3,command=kamen_hod)
kamen.place(x=30,y=350)
def sc_hod():
global player
player='ножницы'
bot_hod()
sc=Button(text='ножницы', width='20', height=3,command=sc_hod)
sc.place(x=180,y=350)
def pa_hod():
global player
player='бумага'
bot_hod()
pa=Button(text='бумага', width='20', height=3,command=pa_hod)
pa.place(x=330,y=350)
score=Label(text=f'{player_points} VS {bot_points}', font='Arial 20')
score.place(x=400,y=20)
result=Label(text='', font='Arial 40')
result.place(x=135,y=150)
hod_bota=Label(text='Выбери чем ходить', font='Arial 20')
hod_bota.place(x=130,y=220)
win.mainloop()
from tkinter import *
import random, threading, time
win=Tk()
win.title('КНБ')
win.geometry('500x500')
player=''
player_points=0
bot_points=0
def animation():
command = ['камень', 'ножницы', 'бумага']
for i in range(100):
bot = random.choice(command)
time.sleep(0.01)
hod_bota['text'] = f'Бот походил - {bot}'
bot_hod()
def bot_hod():
global player,player_points,bot_points
command=['камень','ножницы','бумага']
bot = random.choice(command)
hod_bota['text']=f'Бот походил - {bot}'
if player == bot:
result['text']='ничья!'
elif player == 'камень' and bot == 'ножницы' or player == 'ножницы' and bot == 'бумага' or player == 'бумага' and bot == 'камень':
result['text']='ты победил'
player_points += 1
elif player == 'камень' and bot == 'бумага' or player == 'ножницы' and bot == 'камень' or player == 'бумага' and bot == 'ножницы':
result['text']='ты проиграл'
bot_points += 1
score['text']=f'{player_points} VS {bot_points}'
if player_points==10 or bot_points==10:
kamen.destroy()
sc.destroy()
pa.destroy()
hod_bota.destroy()
if player_points==10 :
result['text'] = 'ты победил'
if bot_points==10:
result['text'] = 'ты проиграл'
def kamen_hod():
global player
player='камень'
threading.Thread(target=animation, daemon=True).start()
kamen=Button(text='камень', width='20', height=3,command=kamen_hod)
kamen.place(x=30,y=350)
def sc_hod():
global player
player='ножницы'
threading.Thread(target=animation, daemon=True).start()
sc=Button(text='ножницы', width='20', height=3,command=sc_hod)
sc.place(x=180,y=350)
def pa_hod():
global player
player='бумага'
threading.Thread(target=animation, daemon=True).start()
pa=Button(text='бумага', width='20', height=3,command=pa_hod)
pa.place(x=330,y=350)
score=Label(text=f'{player_points} VS {bot_points}', font='Arial 20')
score.place(x=400,y=20)
result=Label(text='', font='Arial 40')
result.place(x=135,y=150)
hod_bota=Label(text='Выбери чем ходить', font='Arial 20')
hod_bota.place(x=130,y=220)
win.mainloop()
from tkinter import *
import random
win=Tk()
win.title('x0')
win.geometry('500x500')
def check():
text_win='нет'
if btn1['text']==btn2['text']==btn3['text']!='' or btn4['text']==btn5['text']==btn6['text']!='' or btn7['text']==btn8['text']==btn9['text']!='' :
text_win='да'
if text_win=='да':
txt=Label(text='конец игры')
txt.place(x=30,y=400)
def bot():
check()
if len(bot_knopka)>0:
knopka=random.choice(bot_knopka)
knopka['text']='0'
bot_knopka.remove(knopka)
check()
def btn1c():
if btn1['text']=='':
btn1['text']='X'
bot_knopka.remove(btn1)
bot()
btn1=Button(text='', width=20, height=6, command=btn1c)
btn1.place(x=10,y=30)
def btn2c():
if btn2['text']=='':
btn2['text']='X'
bot_knopka.remove(btn2)
bot()
btn2=Button(text='', width=20, height=6, command=btn2c)
btn2.place(x=170,y=30)
def btn3c():
if btn3['text']=='':
btn3['text']='X'
bot_knopka.remove(btn3)
bot()
btn3=Button(text='', width=20, height=6, command=btn3c)
btn3.place(x=330,y=30)
def btn4c():
if btn4['text']=='':
btn4['text']='X'
bot_knopka.remove(btn4)
bot()
btn4=Button(text='', width=20, height=6, command=btn4c)
btn4.place(x=10,y=140)
def btn5c():
if btn5['text']=='':
btn5['text']='X'
bot_knopka.remove(btn5)
bot()
btn5=Button(text='', width=20, height=6, command=btn5c)
btn5.place(x=170,y=140)
def btn6c():
if btn6['text']=='':
btn6['text']='X'
bot_knopka.remove(btn6)
bot()
btn6=Button(text='', width=20, height=6, command=btn6c)
btn6.place(x=330,y=140)
def btn7c():
if btn7['text']=='':
btn7['text']='X'
bot_knopka.remove(btn7)
bot()
btn7=Button(text='', width=20, height=6, command=btn7c)
btn7.place(x=10,y=250)
def btn8c():
if btn8['text']=='':
btn8['text']='X'
bot_knopka.remove(btn8)
bot()
btn8=Button(text='', width=20, height=6, command=btn8c)
btn8.place(x=170,y=250)
def btn9c():
if btn9['text']=='':
btn9['text']='X'
bot_knopka.remove(btn9)
bot()
btn9=Button(text='', width=20, height=6, command=btn9c)
btn9.place(x=330,y=250)
bot_knopka=[btn1,btn2, btn3, btn4,btn5,btn6, btn7,btn8,btn9]
win.mainloop()