0
from Tkinter import *
import random


root = Tk()
paper = 1
scissors = 2
rock = 0
computer = random.randint(0, 2)


def myScissors():
    if computer == 2:
        print("scissors")
        myLabel = Label(root, text="Tie!")
        myLabel.pack()
        return


def myPaper():
    if computer == 1:
        print("Tie!")
        myLabel = Label(root, text="Tie!")
        myLabel.pack()



def myRock():
    if computer == 0:
        print("Tie!")
        myLabel = Label(root, text="Tie!")
        myLabel.pack()
        return


mySpace = Label(root, text="                        ", padx=50)
myButton = Button(root, text="rock", padx=50,command=myRock())
myButton1 = Button(root, text="paper", padx=50, command=myPaper())
myButton2 = Button(root, text="scissors", padx=50, command=myScissors())


myButton2.pack()
myButton1.pack()
myButton.pack()
mySpace.pack()


root.mainloop()

not finished but at the moment it should appear the label Tie when you click one of the buttons but instead it just appears, without clicking the buttons i dont know why this happens if somone replies, please tell my why it happens

Pipesito
  • 1
  • 2
  • Just change the `command=myRock()` to `command=myRock`.(Remove all the `()` in all the `command`).You will know it after you read this question: [Why is Button parameter “command” executed when declared?](https://stackoverflow.com/questions/5767228/why-is-button-parameter-command-executed-when-declared) – jizhihaoSAMA Apr 21 '20 at 17:02
  • omg thank you so much!!!!. by the way how should i make it for the game repeats when i click again any of the buttons as new choice? – Pipesito Apr 21 '20 at 17:22
  • Well,That's should be another question,You could ask a new one.And you should know,We couldn't post an answer in a closed question.But the idea is easy,you just need to do the thing what you did in the beginning. – jizhihaoSAMA Apr 21 '20 at 17:25

0 Answers0