Hello

Essentially, what I'm thinking of a front end is where the entire view is based 
on a WebKit view, and scripted by python, basically, an an html page but with 
python in the script tag instead of javascript. This is exactly what 
Appcelerator (Apache license) does. Here is a little demo of creating apps with 
Appcelerator:  
http://www.codestrong.com/titanium/guides/python/

Before grad school, I worked for about 7 years developing browser based desktop 
applications. Unfortunately, they were IE based on Windows. As this was 
Windows, all the C++ code was wrapped in COM, and the front end consisted of 
IE, hosting a bunch of vbscript scripts which contained the entire application 
logic. I did learn a thing or two about these types of applications. They are 
fast to develop , and extremely customizable.  All this was before the new 
capabilities in HTML5. The other thing I like about these types of browser 
based applications is I'm a lisp junkie, the big thing about lisp is code and 
data are the same. In browser based applications, code, logic and presentation 
are all the same language. 

Over this weekend, I was thinking over some simpler ideas, such as just 
packaging up sage into a single .app, and with a script that starts the web 
server, and a WebKit view embedded in a Cocoa app does the drawing. But then I 
started reading some more about the new capabilities of HTML 5 and was pretty 
blown away. Take a look at some HTML canvas demos ( You'll need a very recent 
WebKit or Firefox 3.6)
http://www.canvasdemos.com/

Bear in mind that these demos are pure HTML and Javascript. Imagine what would 
be possible 
if Python combined with Sage were used instead of Javascript.

WebKit nightly builds also include WebGL, an open standard by the khronos group 
that gives web application (Javascript) a 3D canvas. Here is a preview of 
WebGL, the 3D canvas in WebKit (You can see it for yourself if you grab one of 
the nightly builds of WebKit):
http://blog.wolfire.com/2009/09/preview-of-webkits-webgl-canvas3d/

Now, again imagine that power of such interactive drawing and layout 
mechanisms, combined with DIRECT access from Python / Sage. All of 2D / 3D 
canvas is natively part of WebKit nightly builds, no plugins, no Java, no 
anything except native WebKit. 

Appcelerator has a module called kroll which provides dynamic binding for all 
of the HTML DOM from / to python. Its probably not the quickest thing in the 
world, but I think thats its well worthwhile to start developing on it, then 
eventually, write a native WebKit / Python binding. 

Now all of this would be obviously possible using a webserver approach, with 
sage generating javascript, transmitting it to a remote browser, handling user 
interaction in javascript, and calling back requests on the server side. But 
this is extremely complex, imagine how much simpler and more powerfull it is to 
have all the interaction handled in python, rather then generating javascript 
and doing posts. 


One of the nice things about WebKit is it has native backends for all the 
popular operating systems: Cocoa, Win32/64, GTK, Haiku, and QT, so it is a 
native
application on all platforms. 

One of the problems I have with QT is that it is more of an operating system 
than a toolkit. I've dug into the QT source, and basically what it does is 
handle all of its own windowing and events, draw everything to a pixmap, and 
then eventually blt this to the screen. Thats why QT apps never look quite 
right on Mac or Windows, they have what is called an 'uncanny valley' effect, 
in that they look similar to native apps, but are just off, yielding a sort of 
creepy feel. Now QT looks fine on Linux, because QT **IS** the native toolkit 
(at least with KDE).

So, in summary, what I'm thinking is a WebKit based application which provides 
incredibly powerful and interactive layout 2D and 3D drawing, and is 100% pure 
python, with a bit of DOM <-> Python glue. No need to bring in QT, GTK, 
Windows, Cocoa, or any other toolkit that is tied to a platform, because WebKit 
is native on all platforms. 




On Jan 9, 2010, at 10:50 PM, ghtdak wrote:

> 
> 
> On Jan 9, 2:20 am, Alejandro Serrano <[email protected]> wrote:
>> Hi,
>> I'm currently developing something very similar as the thing you are
>> proposing. I sent it to the list about two months ago 
>> (http://groups.google.com/group/sage-devel/browse_thread/thread/53b3d6...
>> ). It basically runs one Sage session per thread and uses QtWebKit to
>> communicate with it. The part that emulates the worksheet is working
>> very well. The project is currently in Sourceforge 
>> (http://sourceforge.net/project/screenshots.php?group_id=287015).
>> It is coded using Python, and PyQt. t's architecture is based on plug-
>> ins, so any person can add viewers (parts that tell how to show Sage
>> objects). Now we have viewers for 2-D plots and graphs, but we lack a
>> viewer for 3-D plots, because QtWebKit does not support Java applets,
>> so JMol is not embeddable.
> 
> I've had pretty good luck with Mayavi2.  It gets tricky sometimes
> because not everything works with PyQt yet.  Enthought is headed
> towards Qt but some things are really still Wx.  Then there's the
> whole PyQt going away in favor of PySide one of these days so much of
> the Qt-Python world is unsettled and not as much progress is made as
> folks watch and see.
> 
> OTOH, having VTK integrated more closely with Sage would be great for
> many things.  VTK is truly amazing code but kinda intense to deal
> with.  The Mayavi TvTk wrappers make it much more manageable but is in
> various stages of completeness.  It relies heavily on Traits which I'm
> not fully up to speed on yet.
> 
>> 
>> And of course, any help is needed :) We could build a good replacement
>> for propietary mathematical programs
> 
> Exactly.  I'll take a look at your code.
> 
>> 
>> On 9 ene, 08:48, ghtdak <[email protected]> wrote:
>> 
>> 
>> 
>>> On Jan 8, 1:01 pm, Andy Somogyi <[email protected]> wrote:
>> 
>>>> Thats sort of what I was originally thinking for a first go, but I'm not 
>>>> sure how
>>>> useful it would be in the long term. What would be pretty quick is to 
>>>> create an app, main view
>>>> would be a text editor, say use the editor component from smultron, and 
>>>> extend it so you could have
>>>> mplotlib widgets (mplotlib, with a pdf backend) in the editor.
>> 
>>>> This approach would be a lot quicker than adding a python empowered DOM to 
>>>> webkit, but would not give
>>>> anywhere near the functionality, and much of the code would be Mac 
>>>> specific (no problem for me, but
>>>> not everyone is a Mac user).
>> 
>>>> 3D plots could be handled with google's O3D. Even though O3D is intended 
>>>> as a WebKit plugin, the way it
>>>> creates language bindings is a bit different (and a lot cleaner) then 
>>>> webkit: O3D has set of idl files
>>>> that are processed by a set of python scripts to generate language 
>>>> bindings. These scripts are very
>>>> different then the perl scripts for webkit, and a lot easier to hack. So, 
>>>> its possible to create a
>>>> python enabled O3D component, and also host this in the editor view.
>> 
>>>> With either route, all the graph drawing code would be python, and would 
>>>> not matter much if the
>>>> O3D canvas is hosted in WebKit, or an editor view.
>> 
>>> One approach to a desktop application which might be "relatively"
>>> simple and cross-platform is to use the Qt stuff.  In particular,
>>> using QtWebKit as a component in a window will give you, pretty much,
>>> a full browser which you can get at with C++ code.  With the right
>>> twiddling, you could use PyQt to grab matplotlib graphics for
>>> display.  QtWebKit should support JMol and for hard core 3D I would
>>> just go full out and nail up Mayavi2.  Having the notebook in a window
>>> gives you the full notebook editing for free while you build up
>>> whatever other editing might be better for a native app.
>> 
>>> The tricky bit, as usual, is the event loop.  Ideally, the application
>>> would have access to all the data in a single process. It could
>>> support the web stuff and whatever display code which works best
>>> native.  Building a 3D capability across the wire to replace JMol
>>> would be work.  I think Mayavi2 is a really significant capability
>>> which works great with sage currently and might be a better approach
>>> than O3D but I'm not really familiar with that capability.
>> 
>>> What I currently do, and its a bit of a kludge, is run ipython with
>>> the -q4thread event loop.  I have C++ Qt windows for my custom gui
>>> requirements (invoked through some Cython bridge code), matplotlib
>>> through PyQt and Mayavi2.  I don't currently use the notebook in those
>>> processes because of my use case but twisted is already built into
>>> ipython for their parallel computing capability.  I've had trouble
>>> figuring it out and its sort of a work in progress but the essential
>>> capabilities are there.
>> 
>>> Either way, Qt is a great base because of its web components and its
>>> cross-platform architecture.  While there are some tricky bits to
>>> consider, I think they're "relatively" straightforward and the
>>> underlying event loop issue may be easier now with the notebook
>>> rewrite activity.
>> 
>>>> On Jan 8, 2010, at 2:56 PM, kcrisman wrote:
>> 
>>>>>>> to Mathematica, and Sage, combined with a native front end would be
>>>>>>> the trick.
>> 
>>>>>> I think you should try.  If you can do it, and it works well, and is
>>>>>> maintainable, then we all win.  If the project doesn't work out,
>>>>>> what's the worst than can happen?  You will learn a lot anyways, and
>>>>>> somebody else can pick up your code later.    So go for it!
>> 
>>>>> An interesting more tractable (not for me, sadly) first step would be
>>>>> to use Interface Builder (on Mac) to embed the Terminal and notebook
>>>>> more "natively", and/or create a native front end beyond the current
>>>>> app bundle.  This has been done for other programs, for instance there
>>>>> is (was?) one for Macaulay 2.  Though of course it wouldn't
>>>>> necessarily lead to any usable code for the larger project - just a
>>>>> thought.
>> 
>>>>> - kcrisman
>>>>> --
>>>>> To post to this group, send an email to [email protected]
>>>>> To unsubscribe from this group, send an email to 
>>>>> [email protected]
>>>>> For more options, visit this group 
>>>>> athttp://groups.google.com/group/sage-devel
>>>>> URL:http://www.sagemath.org
> -- 
> To post to this group, send an email to [email protected]
> To unsubscribe from this group, send an email to 
> [email protected]
> For more options, visit this group at 
> http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org

-- 
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to