Hey guys, I'm in an introductory computer science class that deals with Python. We're assigned to create a dice-rolling program using Tkinter, and I have the interface pretty much down, but I'm having trouble linking it to the dice-roller. Here it is.
import random
import Tkinter
win = Tkinter.Tk()
win.title("Die Roller")
class die():
import Tkinter
def __init__(self,ivalue,parent):
self.value = ivalue
self.display = Tkinter.Label(parent,relief='ridge', borderwidth=2, text=str(self.value))
def roll(self):
self.value = random.randint(1,6)
self.display.config(text=str(self.value))
def rollin():
d1.roll
d2.roll
d3.roll
row1 = Tkinter.Frame(win)
row2 = Tkinter.Frame(win)
d1 = die(1,row1)
d2 = die(1,row1)
d3 = die(1,row1)
d1.display.pack(side="left")
d2.display.pack(side="left")
d3.display.pack(side="left")
row1.pack()
rolldice = Tkinter.Button(row2, command=rollin(), text = "Roll")
rolldice.pack()
row2.pack()
win.mainloop()
When I click roll, nothing pops up as an output. Not quite sure what I'm doing wrong here. (Bear in mind Tkinter was just introduced to us a few days ago.)