mercredi 26 juin 2019

config method does not work for my buttons and checkbox widgets what seems to be the problem

i am creating an application that has many widgets including buttons and check boxes and i want to be able change their background colors while it's running by clicking on a button that calls a function that randomly picks colors from a list, it works for labels and frames but the button's and and check boxes gives me an error: AttributeError: 'NoneType' object has no attribute 'config' please help me.

def color2(self): colors2 = ['snow','navajo white','lavender','coral1', 'conflower','blue','cyan3','spring green', 'lightcoral','HotPink2','PeachPuff2','RoyalBlue4', 'yellow','orange2','RosyBrown2','SpringGreen2',
'AntiqueWhite2','turquoise2','plum2']
pick2 = random.choice(colors2)

    #this are buttons
    self.calculator.config(bg=pick2)
    self.btnExit.config(bg=pick2)
    self.btnReceipt.config(bg=pick2)
    self.btnSave.config(bg=pick2)
    self.btnTotal.config(bg=pick2)
    self.btnReset.config(bg=pick2)
    #this are labels
    self.lblCostofDrinks.configure(background=pick2)
    self.lblCostofFood.configure(background=pick2)
    self.lblCostofSnacks.configure(background=pick2)
    self.lblServiceCharge.configure(background=pick2)
    self.lblSubTotal.configure(background=pick2)
    self.lblTotal.configure(background=pick2)
    #this are frames
    self.Buttons_Frame.configure(background=pick2)
    self.RCF.configure(background=pick2)
    self.Receipt_Frame.configure(background=pick2)
    self.MenuFrame.configure(background=pick2)
    self.Food_Frame.configure(background=pick2)
    self.Snacks_Frame.configure(background=pick2)
    self.Drinks_Frame.configure(background=pick2)
    self.Cost_Frame.configure(background=pick2)




Aucun commentaire:

Enregistrer un commentaire