Change the value of the progress bar from a class other than my GUI class PyQt4

帅比萌擦擦* 提交于 2019-12-02 01:47:26

gui.Ui_mainLayout is not an instantiated class but a 'type' object (an object that can be instantiated - see here for a good overview). gui.Ui_mainLayout.progressBar is not going to exist as its created when setupUi is run.

Try passing progressBar to RunProgram explicitly:

from PyQt4 import QtCore, QtGui
from Run import RunProgram

class Ui_mainLayout(QtGui.QWidget):
    def setupUi(self, mainLayout):
        mainLayout.setObjectName(_fromUtf8("mainLayout"))
        def setLayout():
            self.basic_tab = QtGui.QWidget()
            self.progressBar = QtGui.QProgressBar(self.basic_tab)
        setLayout(self.progressBar)
        RunProgram()

and

class RunProgram:
    def __init__(self, progressBar):
        something = someMaths
        progressBar.setValue(something)

I think that will work, but I suggest in future posting a minimal example you expect to run that can form the basis of the explanation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!