I'm relatively new to python 3.6. I was able to change the states of buttons in frame1 but not in frame2 as though the objects in frame2 are in a different namespace. Or is it? Would someone please help? Here is the code:
from tkinter import *
class Raffle():
def __init__(self, master):
self.master = master
master.geometry("280x72")
frame1 = Frame(master, height=1, background="steelblue")
frame2 = Frame(master, height=1, background="powderblue")
self.btnGet = Button(frame1, text="Get Entry", bg="slategray",
fg="whitesmoke", command=self.cmd1)
self.btnGet.pack(side=LEFT, padx=5, pady=5)
self.btnEnum = Button(frame1, text="Break Down", bg="slategray",
fg="whitesmoke", state="disabled", command=self.cmd2)
self.btnEnum.pack(side=LEFT, padx=5)
self.shuf = Button(frame1, text="Shuffle", bg="slategray",
fg="whitesmoke", state="disabled", command=self.cmd3)
self.shuf.pack(side=LEFT, padx=5)
self.quickWin = Button(frame1, text="Winners", bg="slategray",
fg="whitesmoke", state="disabled", command=self.cmd4)
self.quickWin.pack(side=LEFT)
self.reset = Button(frame2, text="Reset", bg="slategray",
fg="whitesmoke", command=self.cmd5)
self.reset.pack(side=RIGHT, padx=10)
self.Draw = Button(frame2, text="Draw",
bg="magenta", fg="yellow", state="disabled",
command=self.cmd6).pack(side=RIGHT, pady=5)
frame1.pack(side=TOP, expand=NO, fill=X)
frame2.pack(side=TOP, expand=NO, fill=X)
def cmd1(self):
self.btnEnum.configure({"state": "normal"})
def cmd2(self):
ab={self.btnGet:0,
self.btnEnum:0,
self.shuf:1,
self.quickWin:1}
#self.draw:1}
self.able(ab)
def cmd3(self):
pass
def cmd4(self):
pass
def cmd5(self):
ab={self.btnGet:1,
self.btnEnum:0,
self.shuf:0,
self.quickWin:0}
#self.draw:0}
self.able(ab)
def cmd6(self):
pass
def able(self, dic):
for widget in dic:
if dic[widget]==0:
widget.configure({"state": "disabled"}) #disables entry
else:
widget.configure({"state": "normal"}) #enables entry
if __name__ == '__main__':
parent = Tk()
app = Raffle(parent)
parent.mainloop()
The buttons in frame1 are just fine, but not the 'draw' button in frame2 which I can't enable or disable. I commented the part referring to that button (draw) because it returns an error as a 'NonType' object. Will someone please help...