0

I'm working on my python script to create the variables for the pixel size between 375 and 1234. When I'm adding the list of buttons, I want to check if the current button are between 375 and 1234 or greater than 1234.

When I'm pressing on the down arrow button of the keyboard, it will check on the pixel size between 375 and 1234, but there is a problem. When I check on the current button that are no greater than 1234 which the pixel size is between 375 and 1234, it will not let me to get pass on if CurrentRow >= pixel_start <= pixel_end:.

I will always get pass on the end of the statement like this:

print "you are in greater than 1234"

Here is the code:

def GoRight(self):
    basex, basey = self.getControl(4207 + self.channels_Index).getPosition()
    basew = self.getControl(4207 + self.channels_Index).getWidth()

    # change program controls to display the proper junks
    if self.channels_Index == len(self.program_buttons[self.programs_Index]) - 1:
        CurrentRow = self.setFocus(self.program_buttons[self.programs_Index][self.channels_Index])
        pixel_start = 375
        pixel_end = 1234

        #Check on pixels size between start and end time
        if CurrentRow >= pixel_start <= pixel_end:
           print "you are in between 375 and 1234"
        else:
           print "you are in greater than 1234"

What I want to achieve is to check on the current button if they are between the pixel size between 375 and 1234 and if they are greater than 1234 then do something.

Does anyone know how I can check on the pixel size if the current button are between 375 and 1234 or if they are greater than 1234?

Frxstrem
  • 38,761
  • 9
  • 79
  • 119
  • 1
    `if pixel_start <= CurrentRow <= pixel_end` presuming `CurrentRow ` is an int, if there is a possibility it is under 375 then you need extra statements – Padraic Cunningham Dec 16 '14 at 17:51
  • @PadraicCunningham thank you very much but it will not check on the CurrentRow for the pixel size between 375 and 1234. Any idea? –  Dec 16 '14 at 17:54
  • If you actually read the question that this is marked as a duplicate of, you would understand why it's marked as such. – Shashank Dec 16 '14 at 17:55
  • @chris, the if statement should check that CurrentRow is between those values but as I said CurrentRow must be an int and if CurrentRow < 375 then you will also reach the else block – Padraic Cunningham Dec 16 '14 at 17:57
  • @PadraicCunningham yeah I know that it should check that if CurrentRow is between those values but when the CurrentRow are greater than 1234, it will not let me to get on the else block. Any idea? –  Dec 16 '14 at 18:00
  • @chris, have you printed the value of CurrentRow in your code to debug? You should always reach the else if you are under 375 or > 1234 with the if statement I posted. – Padraic Cunningham Dec 16 '14 at 18:03
  • @PadraicCunningham yes i did. here it is `18:27:00 T:736 NOTICE: 1073` –  Dec 16 '14 at 18:27
  • 1
    well if that is what CurrentRow is equal to you need `(int(CurrentRow.rsplit()[-1])` presuming the last number 1073 us what you want – Padraic Cunningham Dec 16 '14 at 18:29
  • thanks, can you post the example code please? –  Dec 16 '14 at 18:51

0 Answers0