[Sugar-devel] error in passing image from pygame to js

Sam Parkinson sam.parkinson3 at gmail.com
Wed Jul 16 06:45:01 EDT 2014


Hi,

Are you getting data to send?  Does the loop stop?

Please give us the context (what is this self._client?).

Thanks,
Sam


P.S.  Don't use `while quit_loop:`, use `while True` and `break` to quit
the loop


On Wed, Jul 16, 2014 at 5:08 PM, Puneet Kaur <puneet.gkaur at gmail.com> wrote:

> *Hey,*
>
> *I am working on camera plugin for sugar cordova.*
>
> *I used pygame to click the user's photograph by the following code : *
>
>
>     def camera(self,request):
>         os.environ['SDL_VIDEO_CENTERED'] = '1'
>         pygame.init()
> pygame.camera.init()
>         screen=pygame.display.set_mode((640,480),pygame.NOFRAME )
>     camlist = pygame.camera.list_cameras()
>     if camlist:
>             cam = pygame.camera.Camera(camlist[0],(640,480))
> cam.start()
>         quit_loop=0
>         base64data=None
>         while quit_loop == 0:
>     cam_image=cam.get_image()
>     screen.blit(cam_image,(0,0))
>     pygame.display.update()
>     for event in pygame.event.get():
> if event.type == MOUSEBUTTONDOWN:
>                     data = pygame.image.tostring(screen,"RGBA")
>                     base64data = base64.b64encode(data)
>                     #logging.error("base64 :\n %s",base64data)
>      cam.stop()
>                     pygame.display.quit()
>                     quit_loop=1
>         logging.error("got base64 image")
>         self._client.send_result(request,base64data)
>
>
>
>
> *The issue is that I am not able to send data back to the javascript side
> from python side.*
>
> *I am attaching shell.log along if anyone wishes to have a look over it.*
>
> *would be nice if someone can help me know why am I not able to send the
> data to javascript side.*
>
>
>
>
>
>
> Regards,
> Puneet
>
>
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140716/ddbf39e8/attachment-0001.html>


More information about the Sugar-devel mailing list