This doesn't solve your calls twice problem but should get rid of the duplicate calls to obtain the control.
def GoRight(self): for program_id in self.program_id: ctrl = self.getControl(int(program_id)) # from here on the program_id is the same, so the same control throughout the loop program_width = ctrl.getWidth() if int(ctrl.getX()) != 375: continue if int(program_width) == 691: programs_width = 344 ctrl.setWidth(int(programs_width)) # int not required , an int was assigned to a variable in the previous line program_width = ctrl.getWidth() # this is doing nothing unless there is more code we cant see that uses this variable elif int(program_width) == 167: print "you are working on 167 button" ctrl.setLabel(nextprogram_label) ctrl.setWidth(nextprogram_width)