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
#20
(Oct-25-2016, 06:44 PM)Yoriz Wrote: If you don't even know what gui you are using what chance do you or anyone trying to help have Smash
Looks like it could be this

You have loads of duplicated code, variables that are not used.

ctrl is not defined
if int(ctrl.getX()) != 375: # undefined variable ctrl
           continue
In this part
if int(program_width) == 691: # width of button1
           programs_width = 344
           program_button_1.setWidth(int(programs_width)) # set button one width
           program_width = program_button_1.getWidth() # changed the width to 344
           nextprogram_width = program_button_2.getWidth()
           print "catch this goright 1"
You set button1 to width 344, then you ask the control what its width is that you already know as you just set it and change variable program_width to that width.

In the next part you check for the value of program_width is inside your condition which it is  because you just set it to be and then you change button1 width to the width of button2
 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)


Yeah, but I have to create two different statement for the button when I change it which it can be done by using this:

   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 use the control of program_button_1 to set the width size to 344 that I get the width size from the program_button_2 control and I use to set the program_button_2 width size that I got from the program_button_3 control.

When I run the code under the loop, I have got three button1 that need to set to the width size from 691 to 344, so the code will be executed and change the width size like three times which it should be only once time for each button. It would be easy if I can get one button id when I empty the list in each time when I change the button1 size without I have to run through the loop.
Reply


Messages In This Thread
RE: How to block the code from executed twice under the loop - by chris0147 - Oct-25-2016, 07:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] messagebox is not being executed please help erwinsiuda 2 2,344 Apr-02-2020, 01:56 AM
Last Post: Larz60+
  [Tkinter] Window unresponsive when executed. fawazcode 2 3,848 Sep-11-2017, 12:29 AM
Last Post: Larz60+
  [WxPython] Which def is executed? merlem 10 7,947 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