我不知道该怎么做,以便每次按下按钮时结果标签都应该显示新结果,我应该在重复功能中复制并粘贴 3 个石头、剪纸和剪刀功能还是什么?
它的python 2.7
from Tkinter import*
import random
# variables
a = "rock"
b = "paper"
c = "scissors"
pc = random.choice([a, b, c])
windows = Tk()
windows.geometry("200x300")
# function that makes the
def repeat():
pc = random.choice([a, b, c])
print pc
# im stuck here!
def tie():
lbresult.configure(text="Tie!")
def win():
lbresult.configure(text="you win!!")
def loose():
lbresult.configure(text="you loose")
# functions for each election
def rock():
if pc == "paper":
loose()
elif pc == "rock":
tie()
elif pc == "scissors":
win()
repeat()
def paper():
if pc == "paper":
tie()
elif pc == "rock":
win()
elif pc == "scissors":
loose()
repeat()
def scissors():
if pc == "paper":
win()
elif pc == "rock":
loose()
elif pc == "scissor":
tie()
repeat()
#buttons for choosing options
lbresult = Label(text="result will appear here")
btrock = Button(text=" rock ", command=rock)
btpaper = Button(text=" paper ", command=paper)
btscissors = Button(text="scissors", command=scissors)
btrock.pack()
btpaper.pack()
btscissors.pack()
lbresult.pack()
#result label
windows.mainloop()
请帮助我疯狂地尝试解决这个问题,
如果你能回答,请解释我为什么......我会很感激
跃然一笑
波斯汪
DIEA
相关分类