I'm just playing around with basic GUI code. I have created two check boxes, and a text field below them. I want it to say, "I like Pizza", 'I like Pasta", "I like nothing", or "I like Pizza and Pasta" in the text field depending upon which checkboxes are ticked.
This is the code for creating the checkboxes and text field:
#Create the pizza check box
self.likes_pizza = BooleanVar()
Checkbutton(self, text = "Pizza", variable = self.likes_pizza, command = self.updatePizzaPasta).grid(row = 5, column = 0)
#Create the pasta check box
self.likes_pasta = BooleanVar()
Checkbutton(self, text = "Pasta", variable = self.likes_pasta, command = self.updatePizzaPasta).grid(row = 5, column = 1)
#Create the pizza and pasta text field
self.pp_txt = Text(self, width = 30, height = 1, wrap=WORD)
self.pp_txt.grid(row = 7, column = 0, columnspan = 2)
This is my attempt at what goes into the function:
def updatePizzaPasta(self):
self.pp_txt = ""
if self.likes_pizza.get():
self.pp_txt = "You like Pizza"
Thank you