Python Forum
[xbmc] How to block the code from executed twice under the loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[xbmc] How to block the code from executed twice under the loop
#8
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)
Reply


Messages In This Thread
RE: How to block the code from executed twice under the loop - by Yoriz - Oct-25-2016, 12:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] messagebox is not being executed please help erwinsiuda 2 2,359 Apr-02-2020, 01:56 AM
Last Post: Larz60+
  [Tkinter] Window unresponsive when executed. fawazcode 2 3,874 Sep-11-2017, 12:29 AM
Last Post: Larz60+
  [WxPython] Which def is executed? merlem 10 8,011 Feb-10-2017, 11:28 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020