this is my code below:
class Example(QWidget):
def __init__(self, fname):
self.fname=fname
super().__init__()
self.initUI()
def initUI(self):
#self.cb1 = QCheckBox('all',self)
self.cb2 = QCheckBox('a',self)
self.cb3 = QCheckBox('b',self)
self.cb4 = QCheckBox('c',self)
#for x in range(1, 13):
# locals()['self.cb{0}'.format(x)] = QCheckBox('a',self)
bt = QPushButton('submit',self)
self.resize(300,200)
self.setWindowTitle('sheets selction')
I am trying to increment the self.cb
by input amount of loop, so I want to increment the self.cb
in the loop like self.cb1
, self.cb2
, self.cb3
..., I tried to use locals()
, it works out of the PYQT, but when I try to use it in the initUI
, it doesnt work, does anyone know how to increment it?