[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pygame.error: video system not initialized



On 5/21/10, Lenard Lindstrom <len-l@xxxxxxxxx> wrote:
> Hi Alex and Jake,
>
> Passing the display surface around is not the problem. In fact it is
> good style to keep a reference and pass it to other functions as an
> argument. It lets you reuse those functions for other surfaces if you
> want. I agree with Jake about seeing  the complete program before
> hazarding a guess. It could be something as trivial as calling
> pygame.event.get() after pygame.quit():
The zip file is at
http://www.gateway2somewhere.com/bs.zip
There is no dependency other than pyGame for now, except for in
speech.py which relies on win32 extensions. You can safely replace
every "from speech import speak" line with this method:
def speak(text):
 pygame.display.set_caption(text)
#end def
to avoid any dependencies you do not have.
I do not think I am calling quit too early. I call quit, but in an if
statement that checks for the quit event or the escape key.
>
> Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
> [GCC 4.3.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import pygame
>  >>> pygame.init()
> (6, 0)
>  >>> win = pygame.display.set_mode((200, 100))
>  >>> win.fill((0, 0, 255))
> <rect(0, 0, 200, 100)>
>  >>> pygame.display.flip()
>  >>> evts = pygame.event.get()
>  >>> pygame.quit()
>  >>> evts = pygame.event.get()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> pygame.error: video system not initialized
>  >>>
>
> Lenard
>
> Jake b wrote:
>> Instead of passing win, use pygame.display.get_surface() , to get the
>> screen, and you can get the dimensions from the Surface().
>>
>> I can't tell the solution without seeing more. However , take a look
>> at this Game() class.
>> http://python.pastebin.com/CV4grHzJ
>>
>> It saves a reference to screen, and saves dimensions.
>>
>> Game() class can contain SpriteGroup() to store your objects, and use
>> collision functions. Check out:
>> http://www.pygame.org/docs/tut/SpriteIntro.html
>>
>> --
>> Jake
>
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap