4
In my code, my Entry()
the state
is originally as DISABLED
. To enable entry, the user would need to mark one of the checkbuttons
. Well, at least that’s the idea. What happens is I mark one of the boxes, but the entry is not released so you can type in it. Follow the code excerpt:
self.sum_l = Label(self.root, text = 'Soma', bg = 'Lightskyblue2')
self.sum_s = IntVar()
self.sum_c = Checkbutton(self.root, bg = 'Lightskyblue2', command = self.Sum, variable = self.sum_s)
self.sub_l = Label(self.root, text = 'Subtração', bg = 'Lightskyblue2')
self.sub_s = IntVar()
self.sub_c = Checkbutton(self.root, bg = 'Lightskyblue2', command = self.Sub, variable = self.sub_s)
self.mult_l = Label(self.root, text = 'Multiplicação', bg = 'Lightskyblue2')
self.mult_s = IntVar()
self.mult_c = Checkbutton(self.root, bg = 'Lightskyblue2', command = self.Mult, variable = self.mult_s)
self.div_l = Label(self.root, text = 'Divisão', bg = 'Lightskyblue2')
self.div_s = IntVar()
self.div_c = Checkbutton(self.root, bg = 'Lightskyblue2', command = self.Div, variable = self.div_s)
self.entry = Entry(self.root, bg = 'white')
if any([self.sum_s.get(), self.sub_s.get(), self.mult_s.get(), self.div_s.get()]):
self.entry['state'] = NORMAL
else:
self.entry['state'] = DISABLED
It’s probably something obvious I haven’t noticed. Can anyone tell what it is?
Avoid putting out-of-date code fragments - it’s worth just putting the class and method declaration on the list, and, if need be, skipping lines within the method - for example, lines that are repeated for sub, mult and div widgets, could be marked with a
...
. But the method and class declaration make it easy to view cotnexto for those who help.– jsbueno