You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Solution: Open the Display.py file, which contains the display object used in the program. For me (on a windows machine), is located at: C:\Python27\lib\site-packages\SimpleCV\Display.py On line 599, in the def checkEvents(self): there is a pg.quit() function call then a on line 600 there is self.done =True. After that line add a return statement.
The code in this file then will look like this:
defcheckEvents(self):
""" **SUMMARY** CheckEvents checks the pygame event queue and sets the internal display values based on any new generated events. .. warning:: This method must be called (or :py:meth:`isDone` or :py:meth:`isNotDone`) to perform mouse event checking. **RETURNS** Nothing. """self.mouseWheelUp=self.mouseWheelDown=0self.lastLeftButton=self.mouseLeftself.lastRightButton=self.mouseRightself.leftButtonDown=Noneself.leftButtonUp=Noneself.rightButtonDown=Noneself.rightButtonUp=Noneforeventinpg.event.get():
ifevent.type==pg.QUIT:
pg.quit() #line 599self.done=True#line 600return######THIS LINE WAS ADDED!!!! prevents another pygame call######ifevent.type==pg.MOUSEMOTION:
self.mouseRawX=event.pos[0]
self.mouseRawY=event.pos[1]
x=int((event.pos[0]-self.xoffset)*self.xscale)
y=int((event.pos[1]-self.yoffset)*self.yscale)
(self.mouseX,self.mouseY) =self._clamp(x,y)
self.mouseLeft, self.mouseMiddle, self.mouseRight=event.buttonsifevent.type==pg.MOUSEBUTTONUP:
self._setButtonState(0, event.button)
ifevent.type==pg.MOUSEBUTTONDOWN:
self._setButtonState(1, event.button)
pressed=pg.key.get_pressed()
if( self.lastLeftButton==0andself.mouseLeft==1 ):
self.leftButtonDown= (self.mouseX,self.mouseY)
if( self.lastLeftButton==1andself.mouseLeft==0 ):
self.leftButtonUp= (self.mouseX,self.mouseY)
if( self.lastRightButton==0andself.mouseRight==1 ):
self.rightButtonDown= (self.mouseX,self.mouseY)
if( self.lastRightButton==1andself.mouseRight==0 ):
self.rightButtonUp= (self.mouseX,self.mouseY)
#If ESC pressed, end the displayif(pressed[27] ==1):
self.done=True
What is happening is the program is closing all modules created by pygame (including the window) when pg.quit() is called, then the progam calls a pygame function again on line 615: pressed = pg.key.get_pressed(). Since all the modules are closed, the pygame video system is no longer initialized and therefore an error is thrown that the pygame video system is not initialized. By adding a return statement, pressed = pg.key.get_pressed() is never called and no error is thrown.
The text was updated successfully, but these errors were encountered:
I'm completely new to SimpleCV but playing with the examples in Chapter 2 I found this related issue: pressing ESC returns from the function but doesn't take down the display window. I'd guess anytime self.down is set to True pg.quit() should be called(?)
Multiple people, especially beginners, are having this issue which can be seen on the forums: http://help.simplecv.org/question/1505/error-with-example-from-page-25/ .
Solution: Open the Display.py file, which contains the display object used in the program. For me (on a windows machine), is located at:
C:\Python27\lib\site-packages\SimpleCV\Display.py
On line 599, in thedef checkEvents(self):
there is apg.quit()
function call then a on line 600 there isself.done =True
. After that line add a return statement.The code in this file then will look like this:
What is happening is the program is closing all modules created by pygame (including the window) when
pg.quit()
is called, then the progam calls a pygame function again on line 615:pressed = pg.key.get_pressed()
. Since all the modules are closed, the pygame video system is no longer initialized and therefore an error is thrown that the pygame video system is not initialized. By adding a return statement,pressed = pg.key.get_pressed()
is never called and no error is thrown.The text was updated successfully, but these errors were encountered: