lundi 5 octobre 2020

PyQT5 Designer add checkbox i Python when I have separate file for code

My problem is that I have a file with my UI called xxx.ui. Then as many have suggested I created another python file called test.py where I have put code to use my xxx.ui:

# imports
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import uic
import sys


class Ui(QtWidgets.QMainWindow):
    def __init__(self):
        super(Ui, self).__init__()
        uic.loadUi('xxx.ui', self)
        
        self.show()


app = QtWidgets.QApplication(sys.argv)
window = Ui()
app.exec_()

Up until this stage everything works ok. But now I would like to add a checkbox to my UI whe program starts without messing inside xxx.ui (so the checkbox will be created dynamicaly when the program runs).

How can I do that ???

Thank You in advance.




Aucun commentaire:

Enregistrer un commentaire