Solved!! OMG I'm really stupid!!! The problem was here: discard wx.Rescale(arr[y].width, arr[y].height, wx.IMAGE_QUALITY_HIGH) Run
Of course it should be: discard img.Rescale(arr[y].width, arr[y].height, wx.IMAGE_QUALITY_HIGH) Run wx is just let wx = pyimport("wx") Run I'm trying many different things with wxwidgets. Last time i touched the code was one week ago when i was trying "rescale" and "resize" procs to understand them better. Anywa what Araq said about gdb is true. I was convinced that the problem was in the Paint proc when instead it was before that!!