from PyQt4 import QtCore, QtGui
def __init__(self, tilePath, mapPath, parent=None):
self.commonInit(tilePath, mapPath)
def commonInit(tilePath, mapPath):
# make calls to self.addPixmap()
def __init__(self, parent=None):
# the following causes the error
self.ModelHexMap = ModelHexMap("game.til", "game.map")
# this is the correct way
self.ModelHexMap = ModelHexMap("game.til", "game.map", self)
if __name__ == "__main__":
myapp = MyForm()
myapp.show()
sys.exit(app.exec_())
from PyQt4 import QtCore, QtGui
class ModelHexMap(QtGui.QGraphicsScene):
def __init__(self, tilePath, mapPath, parent=None):
QtGui.QGraphicsScene.__init__(self, parent)
self.commonInit(tilePath, mapPath)
def commonInit(tilePath, mapPath):
# make calls to self.addPixmap()
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
# the following causes the error
self.ModelHexMap = ModelHexMap("game.til", "game.map")
# this is the correct way
self.ModelHexMap = ModelHexMap("game.til", "game.map", self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = MyForm()
myapp.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks