-1

how can I use for to run this commands?

self.BTN0.hide()
self.BTN1.hide()
self.BTN2.hide()
self.BTN3.hide()
self.BTN4.hide()
self.BTN5.hide()
self.BTN6.hide()
self.BTN7.hide()
self.BTN8.hide()
self.label.hide()
self.resetBTN.hide()

I cant use this:

layoutList = ['BTN0','BTN1','BTN2','BTN3','BTN4','BTN5','BTN6','BTN7','BTN8','label','resetBTN']
for item in layoutList:
    self.item.hide()

how can I use variable value in command in python?

  • You created a list of string, so what you're actually trying to run is: `self.'BTN0'.hide` which makes no sense. Try creating a list of objects, i.e without the single quotes. – Asaf Bialystok Sep 16 '21 at 09:50

1 Answers1

1

You could try putting the objects directly in the lsit

layoutList = [self.BTN0,self.BTN1,self.BTN2]
for item in layoutList:
    item.hide()
charelf
  • 3,103
  • 4
  • 29
  • 51