-1

I made an app for my job using PyQt5. It runs on a touch screen so when I click on a textbox, it sends the name of that textbox in a variable (as a string). Then it "summons" an onscreen keyboard. I enter the value and when I press "ok" it checks the variable to know which textbox summoned the keyboard, and then sends the value to that textbox. I have a lot of textboxes. So now what I do is for each tb I will use

if variable = "textbox1":  
    window1.textbox1.setText(KeyboardValue)

What I'd like to do is:

window1.variable.setText(keyboardValue)

so it will use the object name stored in variable. But it just exits with exit code -6, without any explanation. I know there is a method called sender(), but I tried it with the same result.

khelwood
  • 55,782
  • 14
  • 81
  • 108

1 Answers1

0

You store a reference to window1.textbox1 in a variable, and then you can access setText from that variable.

textbox = window1.textbox1

# Elsewhere...

textBox.setText(keyboardValue)
Abion47
  • 22,211
  • 4
  • 65
  • 88