I can get the GUI to display by changing the button command with ,self but the button still wont work. Any suggestion? The main issue is def btnclick() and btn1 command=BtnClick() The rest button does not function either but it can open and display. I was thinking it was an indent error but I tried a few differences without seeing a direct change. I have also tried moving the def classes above and below other lines of code
class MainWindow(Frame):
def __init__(self):
Frame.__init__(self)
self.master.minsize(350,150)
self.grid(sticky=E+W+S+N)
self.save_dir = None #learn more about this: Try being more spasatious , ecfic
self.filename_open = None #learn more about this
top = self.winfo_toplevel()
top.rowconfigure(0, weight=1)
top.columnconfigure(0, weight=1)
rd1 = random.randint(1, 20)
rd2 = random.randint(1, 20)
aiR1 = 20 - rd1
aiR2 = 20 - rd2
totalDif1 = 20 - rd1 - rd2
totalDif2 = 20 - rd1 + rd2
#---------Labels&Names---------#
myLabel = Label(self, text = "tt")
myLabel.grid(row=3, column=0, pady=2, padx=2, sticky=E+W+N+S)
lbl1 = Label(self, text="My Roll", bg="#FFE19E")
lbl1.grid(row=3, column=1, pady=2, padx=2, sticky=E+W+N+S)
lbl2 = Label(self, text = "Ai Roll", bg="#FFE19E")
lbl2.grid(row=3, column=2, pady=2, padx=2, sticky=E+W+N+S)
lbl3 = Label(self, text = "Second Roll", bg="#FFE19E")
lbl3.grid(row=5, column=1, pady=2, padx=2, sticky=E+W+N+S)
lbl4 = Label(self, text = "Ai ReRoll", bg="#FFE19E")
lbl4.grid(row=5, column=2, pady=2, padx=2, sticky=E+W+N+S)
roll1 = Label(self, text=rd1)
roll1.grid(row=4, column=1, pady=2, padx=2, sticky=E+W+N+S)
roll2 = Label(self, text=aiR1)
roll2.grid(row=4, column=2, pady=2, padx=2, sticky=E+W+N+S)
roll3 = Label(self, text=rd2)
roll3.grid(row=6, column=1, pady=2, padx=2, sticky=E+W+N+S)
roll4 = Label(self, text=aiR2)
roll4.grid(row=6, column=2, pady=2, padx=2, sticky=E+W+N+S)
#---------Buttons---------#
btn1 = Button(self, text="Roll", command=BtnClick(), activeforeground="red", relief="raised")
btn1.grid(row=0, column=0, pady=2, padx=2, sticky=E+W+N+S)
btn2 = Button(self, text="grey", command=BtnReset(),relief="raised")
btn2.grid(row=1, column=0, pady=2, padx=2, sticky=E+W+N+S)
def BtnClick():
myLabel = Label(self, text = " ")
def BtnReset():
myLabel = Label(self, text = " ")
if __name__ =="__main__":
d = MainWindow()
d.mainloop()