I have a class with certain number of class variable. Variables are of different types e.g. QLineEdit/QCheckbox....etc. How can I loop over class variable to set a variable value as below:
obj = FindObj()
value = ['100', 'yes', 'False']
i=0
for variable in obj:
if variable.__class__() == 'QLineEdit': # Don't know if it's right
variable.setText(value[i])
i=i+1
elif variable.__class__() == 'QCheckBox':
variable.setChecked(value[i])
i=i+1
import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon
class FindObj():
def __init__(self):
super().__init__()
self.l1 = QLineEdit()
self.l2 = QLineEdit()
self.l3 = QCheckBox()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = FindObj()
sys.exit(app.exec_())