I have 2 classes :
- first class : a "processing class" running some calculation;
- second class : a "ui" class that displays a progress bar and a label.
The goal is, as the calculations of the first class progress, to display the second class interface and update its progress bar.
Here is what I wrote for the calculation class :
from .interface2_dialog import Interface2Dialog class MyCalculation: def __init__(self, parent=None): self.interface2Dialog = Interface2Dialog() def runCalculation(self): self.interface2Dialog.show() # Initialize progress bar self.interface2Dialog.setLabel("initialize...") self.interface2Dialog.setProgressBar(0) # Update progress bar self.interface2Dialog.setLabel("Update...") self.interface2Dialog.setProgressBar(5)
And here is what I wrote for the ui class :
FORM_CLASS, _ = uic.loadUiType(os.path.join( os.path.dirname(__file__), 'interface2_dialog_base.ui')) class Interface2Dialog(QtWidgets.QDialog, FORM_CLASS): def __init__(self, projectDataInput, parent=None): super(Interface2Dialog, self).__init__(parent) self.setupUi(self) self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) def setProgressBar(self, myValue): # Set progress bar percent value self.progressBarUi.setValue(myValue) def setLabel(self, myValue): # Set label name self.labelUi.setText(myValue)
The method "runCalculation" is the one being called.
"progressBarUi" is the ui progress bar object, as created with QtDesigner.
"labelUi" is the ui label object as created with QtDesigner as well.
Since it does not work, I suppose I did something wrong. The calculation is being run to the end, the ui is displayed on the foregrount, but it is empty.
Why is it empty ? My window should at least be initialized with QtDesigner.