Oct-25-2016, 05:08 PM
@Yoriz: Thank you very much for this, I have changed the code and I ran the test, but I still get the same results. It will keep looping when I use the same program ids as it will change the object texts and size from two different objects button where I want to change the size from one of those object size.
Here is what I use:
How I can get the program id at a time as I use this to store the program id?
Here is what I use:
def GoRight(self): for program_id in self.program_id: nextprogram = int(program_id) + 1 nextprogram1 = int(nextprogram) + 1 nextprogram2 = int(nextprogram1) + 1 nextprogram3 = int(nextprogram2) + 1 program_button_1 = self.getControl(int(program_id)) program_button_2 = self.getControl(int(nextprogram)) program_button_3 = self.getControl(int(nextprogram1)) program_button_4= self.getControl(int(nextprogram2)) program_button_5 = self.getControl(int(nextprogram3)) program_width = program_button_1.getWidth() programX = program_button_1.getX() pos_X = program_button_1.getX() pos_Y = program_button_1.getY() nextprogramX = program_button_2.getX() nextprogram_width = program_button_2.getWidth() nextprogram_label = program_button_2.getLabel() nextprogram1X = program_button_3.getX() nextprogram1_width = program_button_3.getWidth() nextprogram1_label = program_button_3.getLabel() nextprogram2X = program_button_4.getX() nextprogram2_width = program_button_4.getWidth() nextprogram2_label = program_button_4.getLabel() nextprogram3X = program_button_5.getX() nextprogram3_width = program_button_5.getWidth() nextprogram3_label = program_button_5.getLabel() if int(ctrl.getX()) != 375: continue if int(program_width) == 691: programs_width = 344 program_button_1.setWidth(int(programs_width)) program_width = program_button_1.getWidth() nextprogram_width = program_button_2.getWidth() print "catch this goright 1" elif int(program_width) >= 342 and int(program_width) <= 344: #print "you are working on 342 and 344 button" print "catch this goright 2" program_button_1.setLabel(nextprogram_label) program_button_1.setWidth(nextprogram_width) program_button_2.setLabel(nextprogram1_label) program_button_2.setWidth(nextprogram1_width) program_button_3.setLabel(nextprogram2_label) program_button_3.setWidth(nextprogram2_width)I have found the problem is coming from the loops, because I got three buttons that required to change the texts and size, so it will executing like three times. It would be much easier if I could get a single program id at a time to change the text and size at a time without looping like 3 times.
How I can get the program id at a time as I use this to store the program id?
program_button = [elem.control for elem in self.program_buttons] programs_id = list() positions_X = list() for elem in program_button: programs_id.append(elem.getId()) positions_X.append(elem.getX()) programs_id = map(str, programs_id) posX = map(str, positions_X) #Store the list of strings in the lists for i in range(len(posX)): pos_X = posX[i] if pos_X == '375': self.program_id.append(programs_id[i])