I am at a standstill, and after an excessive (and unsuccessful) Google search, I need help.
I am creating a simple PyQt4 widget in which it consists of a grid of 60x80 squares, each of which has a value of None . If the user clicks on this field, it changes color depending on how many times left-clicked, defined by this list:
self.COLORS=[ (0, 0, 255), #WATER (255, 210, 128), #SAND (0, 128, 0), #GREEN (255, 255, 0), #YELLOW (255, 165, 0), #ORANGE (255, 0, 0) #RED ]
If the user right-clicks, he fills the area using the usual recursive filling algorithm. This works great for small spaces, however, if the space is large enough, the program exits with a Fatal Python error: Cannot recover from stack overflow. I have no idea how to fix this, perhaps a fill that is not recursive?
All squares and subsequent color codes are stored in self.cells therefore, setting self.cells[(y,x)]=1 , set the cells (y,x) to Sand .
Here is the program as a whole.
import sys from PyQt4 import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self, cell_size=10, swidth=800, sheight=600): QtGui.QWidget.__init__(self) self.resize(swidth,sheight) self.cell_size = cell_size self.height = sheight self.width = swidth self.columns = self.width
Can someone help diagnose the problem, or perhaps indicate a direction to solve it?