[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] video error
- To: pygame-users@xxxxxxxx
- Subject: [pygame] video error
- From: "Eric Hunter" <hunter.eric1@xxxxxxxxx>
- Date: Wed, 26 Sep 2007 21:01:55 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Wed, 26 Sep 2007 21:02:06 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=08H4tduTpWJD92Wv1qFy+7Mcxf0vBSQbGS08Pdu3Tpg=; b=g2ecvDxqa8TWrfv5IfreuracKWrKv4w58WqCofkBgDcvqvFVE7/2wOsA/AEr/KP7BIM/oCHRwJ4S221ZeDL97/BvmziuQknIJdnaPnIf2N6bUMOU5i7xdsWbAox6ZxoOasiktW8G2x6ruUdp1hQPhtT4Pqm7zjqB4G454nY4GzQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=nDg7zBKwQcjfeSXz2XJ+8wi1MyjrJDgLZ/jvCS/ingM4i4mW9JEeBmSV/AELCrhLhuFG8+cpOFWdCA+6drIrcz7XbyPHUvkn9C9jhpDEgl5xD86s2R35IHfjG6NFLSBUta5LPvP6LaCNCDcNpxUMiyRpgWkqH1EZBs6BCzIFnIU=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
can't understand why I'm getting this error. everything looks okay to me. but then again I'm a newbie. thanks in advance.
Traceback (most recent call last):
File "las.py", line 54, in <module>
class PygameClass():
File "las.py", line 78, in PygameClass
for event in pygame.event.get():
pygame.error: video system not initialized
[code]
class PygameClass():
# Starts Pygame
def __init__(self, full_path):
pygame.init()
self.window = pygame.display.set_mode((1,1), pygame.RESIZABLE)
self.image_name = os.path.basename(full_path)
pygame.display.set_caption(self.image_name)
self.image = pygame.image.load(full_path)
self.image = self.image.convert()
self.image_rect = self.image.get_rect()
print self.image_rect
print self.image_rect.width
print self.image_rect.height
self.window = pygame.display.set_mode((self.image_rect.width, self.image_rect.height))
self.window = self.window.convert()
self.point_draw = 1
self.numRect = 0
rect = {}
self.screen.blit(self.image, (0, 0))
pygame.display.flip()
while True:
for event in pygame.event.get():
if self.event.type == QUIT:
pygame.quit()
sys.exit()
elif self.event.type == pygame.KEYDOWN:
if self.event.key == K_s:
self.out_file = open("text.txt", "w")
pickle.dump(rect, self.out_file)
print "memory dumped."
self.out_file.close()
if self.event.key == K_o:
self.in_file = open('text.txt', 'r')
rect = pickle.load(self.in_file
)
print "memory loaded."
self.in_file.close()
elif self.event.type == pygame.MOUSEBUTTONDOWN:
if self.event.button == 1:
# If point_draw = 1, get x,y of mouse
if self.point_draw == 1:
self.mouseX1, self.mouseY1 = pygame.mouse.get_pos()
self.point_draw
= 2
else:
# If point_draw = 2, get x,y of mouse, make a rect and throw it in a dictionary
self.mouseX2, self.mouseY2 = pygame.mouse.get_pos()
self.numRect += 1
self.newRect = pygame.Rect(self.mouseX1, self.mouseY1, self.mouseX2 - self.mouseX1, self.mouseY2 - self.mouseY1)
rect[self.numRect
] = self.newRect
self.point_draw = 1
elif self.event.button == 3:
self.mouseXTEMP, self.mouseYTEMP = pygame.mouse.get_pos()
for self.x
in rect.keys():
if rect[self.x].collidepoint(self.mouseXTEMP, mself.ouseYTEMP):
del rect[x]
self.numRect -= 1
# draws the rectangles in the rect{}
for self.x in rect.keys():
pygame.draw.rect(window, ((255, 255, 0)), rect[self.x], 1)
pygame.display.flip()
[/code]