builtins.ValueError: sequence size mismatch - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Game Development (https://python-forum.io/forum-11.html) +--- Thread: builtins.ValueError: sequence size mismatch (/thread-15880.html) |
builtins.ValueError: sequence size mismatch - Ruggero - Feb-04-2019 As a beginner I wrote a simple code to draw some shapes on the screen. When I runned it I got a Fatal Python error (pygame parachute) Segmentation Fault. I could isolate the problem to calling a pixelArray of one pixel. When I run this simplified code I get a File ..., line 9, in <module> pixArray[480][380] = BLACK builtins.ValueError: sequence size mismatch import pygame, sys from pygame.locals import * pygame.init() BLACK=[0,0,0] WHITE=[255,255,255] windowSurface = pygame.display.set_mode((500,400),0,32) windowSurface.fill(WHITE) pixArray = pygame.PixelArray(windowSurface) pixArray[480][380] = BLACK del pixArray pygame.display.update() while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit()What does this mean? What is going wrong? RE: builtins.ValueError: sequence size mismatch - Windspar - Feb-05-2019 1. Let pygame choose best depth. windowSurface = pygame.display.set_mode((500,400))2. PixelArrays are like NumPy Arrays pixArray[480, 380] = pygame.Color('Black') 3. pygame.display.update() belongs in main loop. while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() pygame.display.update() RE: builtins.ValueError: sequence size mismatch - Ruggero - Feb-05-2019 Thanks ! |