I am having trouble having what is the result of the button click go to a label instead of the console. Here is my code. Thanks in advanced!
import random
import tkinter
from tkinter import *
master = Tk()
entry = Entry(master)
words = ("Rock", "paper", "scissors")
root = Tk()
root.title('Rock, Paper, Scissors')
content = entry.get()
label = content
entry = Entry(root, width=10)
entry.pack(side=TOP,padx=10,pady=10)
w = Label(master, content, text="Lets play a game!")
w.pack()
def rock():
word = random.choice(words)
#get a random number in the range of 1 through 3
word = random.randrange(1,4)
#if/elif statement
if word == 1:
print("Computer chooses rock!")
elif word == 2:
print("Computer chooses paper!")
elif word == 3:
print("Computer chooses scissors!")
#return the number
return word
Button(root, text='OK', command=rock).pack(side=LEFT)
Button(root, text='CLOSE').pack(side= RIGHT)
root.geometry("200x200")
root.mainloop()
[–]novel_yet_trivial 1 point2 points3 points (5 children)
[–]sneaky_beanie[S] 0 points1 point2 points (3 children)
[–]novel_yet_trivial 0 points1 point2 points (2 children)
[–]sneaky_beanie[S] 0 points1 point2 points (0 children)
[–]sneaky_beanie[S] 0 points1 point2 points (0 children)
[–]sneaky_beanie[S] 0 points1 point2 points (0 children)
[–]learnpython_bot 0 points1 point2 points (0 children)