I am trying to add Maccept method to the ImageDialog class and connect this to okButton. However when I compile this code it will give : AttributeError: 'ImageDialog' object has no attribute 'Maccept' But I have already defined Maccept method inside the class.
from PyQt5.QtWidgets import QDialog,QApplication
from ui_imagedialog import Ui_ImageDialog
import sys
class ImageDialog(QDialog):
def __init__(self):
super(ImageDialog, self).__init__()
# Set up the user interface from Designer.
self.ui = Ui_ImageDialog()
self.ui.setupUi(self)
# Make some local modifications.
#self.ui.colorDepthCombo.addItem("2 colors (1 bit per pixel)")
# Connect up the buttons.
self.ui.okButton.clicked.connect(self.Maccept())
self.ui.cancelButton.clicked.connect(self.reject)
def Maccept(self):
print 'accept'
def main():
app=QApplication(sys.argv)
window=ImageDialog()
window.show()
sys.exit(app.exec_())
if __name__=='__main__':
main()