0

i am new to python, please help me with this problem i have created a tab widget and have button in tab widget,on clicking that button i need to display a new window/dialog containing 4 to 5 line edits but i am getting attribute error when calling method on button click please help me from this problem this is my code

 class TabDialog(QtGui.QDialog):

    def __init__(self, fileName, parent=None):
    super(TabDialog, self).__init__(parent)

    fileInfo = QtCore.QFileInfo(fileName)

    tabWidget = QtGui.QTabWidget()
    tabWidget.addTab(PatientTab(fileInfo), "Patient Info")
     ....
class NewWindow(QtGui.QDialog):
def __init__(self, parent=None):
        super(MyWindow, self).__init__(parent)

    group1= QtGui.QGroupBox("Add Data")
    patientName = QtGui.QLabel("Name")
    patientEdit = QtGui.QLineEdit()

    patientid = QtGui.QLabel("Id")
    patientidEdit = QtGui.QLineEdit()

    genderlabel = QtGui.QLabel("Gender")
    patientgend = QtGui.QLineEdit()

    eyeType = QtGui.QLabel("Eye Type")
    eyeTypeEdit = QtGui.QLineEdit()

    AddData = QtGui.QPushButton("Add Data")

            databaseLayout = QTGui.QGridLayout()
    databaseLayout.addWidget(patientName,0,0)
        databaseLayout.addWidget(patientEdit,0,1)
        databaseLayout.addWidget(patientid,1,0)
        databaseLayout.addWidget(patientidEdit,1,1)
        databaseLayout.addWidget(genderLabel,2,0)
        databaseLayout.addWidget(patientgend,2,1)
        databaseLayout.addWidget(eyeType,3,0)
        databaseLayout.addWidget(eyeTypeEdit,3,1)
        databaseLayout.addWidget(AddData,4,10)

        group1.setLayout(databaseLayout)

    mainLayout = QtGui.QVBoxLayout()
    mainLayout.addWidget(group1)
    mainLayout.addStretch(1)
    self.setLayout(mainLayout)

class PatientTab(QtGui.QWidget):

  def __init__(self, fileInfo, parent=None):
    super(PatientTab, self).__init__(parent)

    self.buttonGroup = QtGui.QGroupBox()
    self.newButton = QtGui.QPushButton(self)
self.newButton.setText("New")
    ***self.newButton.clicked.connect(self.newButton_Clicked)
    .........
    self.newWindow = NewWindow(self)


def newButton_Clicked(self):
    self.newWindow.exec_()

the line started with * is where i am getting error AttributeError: 'PatientTab' object has no attribute 'newButton_Clicked' where i am going wrong please help......

1 Answer 1

1

Is the indentation in your question the same as in your code?

It appears that your newButton_Clicked method is declared outside the scope of the PatientTab class. That would be why your PatientTab does note have a self.newButton_Clicked attribute...

Sign up to request clarification or add additional context in comments.

1 Comment

@darshankatari ... you're welcome. The accepted way to say thanks is to accept the answer, and maybe vote it up ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.