change rgba with key

Hi, i think i’am starting to see how the code works, but it isn’t a quick start.

I want to change the color on the stoke of a key.

I think my code is to simple, can somebody point me in the right direction.

    
self.accept( "s", if (self.auto1.find("**/koplampen").getColor()=(0.870588, 0.835294, 0.588235, 1):
        self.auto1.find("**/koplampen").setColor(0,0.87,0.24,1)
    else:
        self.auto1.find("**/koplampen").setColor(0.870588, 0.835294, 0.588235, 1)

thanks

You can’t specify code in self.accept, only functions:

    
def __init(self):
  self.accept( "s",self.changeColor())
def changeColor(self):
  if (self.auto1.find("**/koplampen").getColor()==(0.870588, 0.835294, 0.588235, 1)):
    self.auto1.find("**/koplampen").setColor(0,0.87,0.24,1)
  else:
    self.auto1.find("**/koplampen").setColor(0.870588, 0.835294, 0.588235, 1)

And PLEASE NOTE that this is wrong:

if(expr1=expr2):

This is the most common cause of errors in most programming languages. What this actually means:

expr1=expr2
if(that succeeded (it always does)):

In comparisions, always use ==:

if(expr1==expr2):