tag:blogger.com,1999:blog-9266717.post113870127340277586..comments2023-05-22T10:01:23.167-03:00Comments on Only Python: Showcasing Python: rur-ple on the web?André Robergehttp://www.blogger.com/profile/08131391818998844540noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-9266717.post-1138751814805058332006-01-31T19:56:00.000-04:002006-01-31T19:56:00.000-04:00Ian:Actually, instead of having HTML [instead of j...Ian:<BR/><BR/>Actually, instead of having HTML [instead of just using repr(), as you mentioned], I was thinking that what could be sent back from the server could be a series of "states" representing the image to be displayed. For example [(1,1), (1,2), (2,2)] could be taken as asking to display the robot at position (1,1), wait for a preset time amount, display it again at (1,2), wait ..., etc. Of course this is overly simplified. Javascript would be used to interpret this series of states.<BR/>So, the user would write the code in a window (html frame?) click a button; the code is sent back to the server, where it is interpreted by Python, which sends back a series of "states" which are then turned into an animation with some javascript code on the client side, animating a picture in a separate frame?...<BR/><BR/>I think what I will do (after I complete version 1.0 of rur-ple) is decouple the logic from the gui handling and try to rebuild it (still as a Python app) along the same line as I describe above - except that everything would be done in Python of course! Then, I could try a local version with some javascript handling the visual display from a state. After that, I'll shout "HELP" and see if someone is willing to implement the server-client "stuff".<BR/><BR/>That is to say, unless someone demonstrates to me that what I describe is nonsensical - or come up with a simpler way.<BR/><BR/>Of course, I won't refuse help from anyone in the meantime;-)André Robergehttps://www.blogger.com/profile/08131391818998844540noreply@blogger.comtag:blogger.com,1999:blog-9266717.post-1138750077065390142006-01-31T19:27:00.000-04:002006-01-31T19:27:00.000-04:00If you want to do this right, you'll have to use q...If you want to do this right, you'll have to use quite a bit of Javascript. But that's okay -- it doesn't mean you have to make the app user deal with Javascript.<BR/><BR/>I doubt it will look much like normal graphical programming, but maybe that's fine. One thing that can be interesting is that instead of just the standard REPL loop that these apps provide, it wouldn't be a long step to allow object to have html representations, so instead of just using repr() to show what the result of the last line was, you could show arbitrary HTML. That HTML could be interactive on the client side of course. That HTML could also call back to the original object, and so represent a connection with the server state, which is where it gets more interesting.<BR/><BR/>In that model the "widgets" are largely implemented in Javascript, and presumably you would be providing them as part of a standard library provided. If you look at the Try Ruby tutorial, it involves some of this, though I don't know if it goes as far as actual RPC and callbacks. Anyway, then you'd be building them up in Python, and the HTML and Javascript would be part of seemingly opaque objects. <BR/><BR/>The hard part is server push, though -- where anything starts from something on the server (and thus where anything starts from Python at all). Instead it all has to happen in response to a client-side action, like the user hitting Enter or clicking on something. Using Twisted and LivePage you can get server-side events, or using a polling loop where you constantly ask "anything yet?" -- and maybe Aquarium would also allow it (Aquarium uses some similar techniques to Twisted, but by using the Stackless Python interpreter it makes them easier to work with.)<BR/><BR/>Anyway, I think it could be very interesting. Also it could let users create fun little web applications, which is easy to work with (no software install) and in particular is easy to share (which is a big motivator).Ian Bickinghttps://www.blogger.com/profile/10921115783730718101noreply@blogger.com