0

I am working on the code to input the numbers in the string self.EPG_DIGIT_NUMBER when I'm pressing on the keyboard number buttons. I would like to add the empty string like this in each time when I press on the keyboard number buttons.

DIGIT_BUTTONS = range(58, 68)

if action.getId() in DIGIT_BUTTONS:
    EPG_DIGIT_NUMBER = len(self.EPG_DIGIT)

    if EPG_DIGIT_NUMBER <= 2:
       self.EPG_DIGIT_NUMBER += str(action.getId() - 58)
    self.EPG_DIGIT += 1
    self.getControl(413).setLabel('[B]' + self.EPG_DIGIT_NUMBER + '[/B]')

When I press on the keyboard numbers 1,0,3, it will show 103 in the string. What I want to achieve is when I press on the keyboard number buttons 1,0,3, I want to make the string to show something is like: 1 0 3. How I can do that?

10
  • You mean '\t'.join(str(123)) Commented Oct 16, 2017 at 0:46
  • @Unni No what I mean is I have the string 103 I would like to make it get seperate which make it to show something is like 1 0 3. How I can do that? Commented Oct 16, 2017 at 0:52
  • Is this what you mean ' '.join(list("103"))? Commented Oct 16, 2017 at 0:52
  • @whackamadoodle3000 No, what I mean is when I press on the 1 button of the keyboard, the sting will show 1, so I press on the 0 button of the keyboard to make it to show 10. I want to make the space string which show 1 0 and when I press 3 button on the keyboard to make to show 1 03 so I want to make the space to make it to show 1 0 3. How I can do that?? Commented Oct 16, 2017 at 0:56
  • 1
    self.EPG_DIGIT_NUMBER += (str(action.getId() - 58)+' '), right? Commented Oct 16, 2017 at 1:04

2 Answers 2

1

Change self.EPG_DIGIT_NUMBER += str(action.getId() - 58) to self.EPG_DIGIT_NUMBER += (str(action.getId() - 58)+' ') so that a space gets appended to the end of the number after each time a number is pressed.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use ' '.join(str("your_string_here"))

1 Comment

This is clearly not the answer, as shown in the comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.