19 Haziran 2014 Perşembe

Week 4&5: JSON Protocol and Implementation

Hello reader,

Last week I have my final exams and my thesis defence. Also, last week we have finished the JSON protocol. But, since I have nothing much to say I am going to post two weeks work in one post.

This week we tried to implement the interactivity part on IPython notebook. We have done a proof of concept using rain.py before, so I decided to re-use it again - Houston, we have a problem.

In rain.py, the GLUT backend is used, like most of the Vispy's demos. GLUT has a function named "glutMainLoop()" which enters the GLUT event processing loop. This is ok, but once called, this routine never returns. At this point our problem occurs. Since this function takes over control, our widgets stop syncing with Python. Thus, we are unable to handle user events!

We are currently searching a solution for that. Vispy-devs currently suggesting to avoid GLUT in such case.

Next post: The Solution (I hope!)

See you next post!


3 Haziran 2014 Salı

Week 3: Design of a JSON Protocol

Hello reader,

We are going to try handling user actions in the HTML canvas - where our visualization occurs. We have done something like that before but without IPython. Now it is time to try it in the IPython notebook. We are using JavaScript for listening the events on a canvas. So we need a protocol for sending this events to Vispy from JavaScript. Thus, we are designing a JSON protocol.

About the implementation, we are going to focus on the IPython notebook for now. It seems we have two options for that:

1- A Javascript function generates a JSON with the events, following user actions. This JSON is sent to Python via a Unicode trait in the widget. A Python callback function is automatically called when this trait is updated: it parses the JSON, generates the Event instances and passes them to Vispy.

2- We get closer to the widget machinery, following something like this.The idea is to write Python callbacks for user actions on browser's side. The widget machinery makes that possible in a clean way. Javascript is responsible for sending the appropriate properties (those that are defined in the JSON protocol) to the Python callbacks. The Python callback functions are responsible for raising the Vispy events.

My mentor (Cyrille Rossant) and I think the second approach is more elegant and straightforward. So we are concentrating on the former.

Back to the JSON protocol, we are trying to follow the same nomenclature and hierarchy as what is currently implemented in vispy.app. So far I wrote nearly half of it. It seems we need one or two weeks to implement these ideas.

Next week: Finishing Touches on JSON Protocol
See you next week!