Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to create labels at run time
TejG last edited by
I have an array that gets populated based on the name of the processes at run time.For each process that is running I want to create a label and checkbox how can I do it using PyQT.I was able to do this in tkinter by using a for loop but dont know regarding Pyqt?
Denni 0 Banned last edited by
Pretty much the same way however I would create a Class that represents the object you want to create and then just instantiate additional objects as needed. Keep in mind that tkinter and pyqt5 are just different libraries to render the GUI it is still python underneath and its the python that does this kind of work.
JonB last edited by
for name in array_of_names: label = QLabel(name, self) checkbox = QCheckBox(name, self) # do something with these, like add them to your layout ...
As @Denni-0 says, you might to create a "composite"
QWidgetwhich holds both the label & the checkbox, laid out as desired, rather than keeping them as separate widgets.