NameError:未定义全局名称“Ui_DiabeticRetinopathy3”

时间:2014-08-24 23:08:20

标签: python-2.7 pyqt4

我正在开发一个多形式应用程序,我可以将(form1到form2和form3),(form2到form3)链接起来,但是当我尝试创建从(form2到form1)和from3到(form2)的链接时或form1)链接到向后页面它给我错误NameError: global name is not defined

这是我的调用方法代码,其中form3可以调用form4但是form4不调用form3;

代码:form3.py

class Ui_DiabeticRetinopathy3(QtGui.QMainWindow):
    def __init__(self,parent=None):
        super(Ui_DiabeticRetinopathy3, self).__init__(parent)
        self.imgPreProc = imagePreProcessor()
        #self.imgPreProc = imagePreProcessor()
        self.setupUi(self)

    def setupUi(self, DiabeticRetinopathy):
        DiabeticRetinopathy.setObjectName(_fromUtf8("DiabeticRetinopathy"))
        DiabeticRetinopathy.resize(672, 608)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8("../im0003.jpg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        DiabeticRetinopathy.setWindowIcon(icon)
        self.pushButton_6 = QtGui.QPushButton(self.verticalLayoutWidget_2)
        self.pushButton_6.setStyleSheet(_fromUtf8("background-color: rgb(191, 191, 191);\n"
"font: 75 8pt \"Verdana\";"))
        self.pushButton_6.setObjectName(_fromUtf8("pushButton_6"))
        self.verticalLayout_2.addWidget(self.pushButton_6)
        self.pushButton_6.clicked.connect(self.on_clicked_hemo)

    def on_clicked_hemo(self):
        self.obj4=Ui_DiabeticRetinopathy4(self)
        self.obj4.show()

代码:form4.py

class Ui_DiabeticRetinopathy4(QtGui.QMainWindow):
    def __init__(self,parent=None):
        super(Ui_DiabeticRetinopathy4, self).__init__(parent)
        self.imgPreProc = imagePreProcessor()
        #self.obj3=Ui_DiabeticRetinopathy3()
        #self.imgPreProc = imagePreProcessor()
        self.setupUi(self)

    def setupUi(self, DiabeticRetinopathy):
        DiabeticRetinopathy.setObjectName(_fromUtf8("DiabeticRetinopathy"))
        DiabeticRetinopathy.resize(672, 608)
        DiabeticRetinopathy.setWindowIcon(icon)
        self.pushButton_6 = QtGui.QPushButton(self.verticalLayoutWidget) 
        self.pushButton_6.setObjectName(_fromUtf8("pushButton_6"))
        self.verticalLayout_2.addWidget(self.pushButton_6)
        #self.pushButton_6.clicked.connect(self.on_clicked_micro)#####

    def on_clicked_micro(self):
        self.obj3=Ui_DiabeticRetinopathy3(self)
        #self.obj3.setupUi(self)
        self.obj3.show()

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

  

NameError:名称'Ui_DiabeticRetinopathy3'未定义

如果有可能,请检查您的导入模块。您是否已将form3.py导入form4.py

form4.py中,应该是这样的可能性;

from form3 import *
from form3 import Ui_DiabeticRetinopathy3