AttributeError: The object 'NoneType & # 39; does not have attribute 'scenePos & # 39;

Here is my sample code. I want to print the coordinates of my x, y positions with the help of the mouse press event. I have this error. Please, help me and I want to display the graphic view in the middle of the scrollArea screen.

Below is my code:

since pyface.qt import QtGui, QtCore
import system

MyView class (QtGui.QGraphicsView):
def __init __ (auto):
QtGui.QGraphicsView .__ init __ (self)
self.row = 2
auto.cols = 4
self.scene = QtGui.QGraphicsScene (0,0500,500)
self.List = []

        for i in the range (self.row):
for j in the range (self.cols):
item = self.scene.addRect (QtCore.QRectF (0,0,30,30))
item.setPos (30 + j * 30,500-i * 30-60)
print item.scenePos ()
self.List.append (item)
self.setScene (self.scene)
def mousePressEvent (self, event):
super (MyView, auto) .mousePressEvent (event)
p = QtCore.QPointF (event.pos ())
print "positonnnnnnnnnnnnnnnnn", p
item = self.scene.itemAt (p)
print "@@@@@@@@@@@@@@@@@@@@@@@@@"
print item.scenePos ()
Class Parameters (QtGui.QMainWindow):
def __init __ (self, parent = None):
super (Settings, auto) .__ init __ (parent)
spacer = QtGui.QWidget (auto)
spacer.setSizePolicy (QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
QtGui.QToolTip.setFont (QtGui.QFont (& # 39; SansSerif & # 39 ;, 10))
self.vbox = QtGui.QVBoxLayout ()
self.save = QtGui.QPushButton ("save")
self.open = QtGui.QPushButton ("open")
self.folder = QtGui.QPushButton ("Folder")
self.folder.clicked.connect (self.showSettings)
self.vbox.addWidget (self.save)
self.vbox.addWidget (self.open)
self.vbox.addWidget (self.folder)
self.grid = QtGui.QGridLayout ()
self.grid.addLayout (self.vbox, 0,0)
self.scrollArea = QtGui.QScrollArea ()
self.scrollArea.setBackgroundRole (QtGui.QPalette.Light)
self.scrollArea.setWidgetResizable (True)
self.grid.addWidget (self.scrollArea, 0,1)
self.setCentralWidget (QtGui.QWidget (auto))
self.centralWidget (). setLayout (self.grid)
self.setGeometry (200, 100, 300, 300)
auto.show ()
def showSettings (auto):
self.newwidget = QtGui.QWidget ()
self.glayout = QtGui.QGridLayout (self.newwidget)
self.MyView = MyView ()
self.glayout.addWidget (self.MyView, 0,1)
self.scrollArea.setWidget (self.newwidget)
def ():
app = QtGui.QApplication (sys.argv)
ex = Parameters ()
sys.exit (app.exec_ ())
if __name__ == __ __ hand __:
main ()