so I fixed most of the early bugs, here is my latest attempt:
http://4.latest.pythonnb.appspot.com/
it seems to be working reasonably well in most browsers I tried (FF,
IE, Safari, Opera, Chrome, ...).
Opera can't handle event.preventDefault(), which means that if you
press shift+enter, the enter will still get propagated and the new
cell will have 2 rows. I think it's a bug in Opera, but maybe there is
some fix for this. All other browsers seem to work for me.
It's not as polished as my original javascript version:
e.g. the evaluate button is not there, and the blue line is not there
yet either, neither is the blue focus rectangle around cells. I will
not have time for the next month or so to work on this, but I am now
confident that it can be done.
Look at the code here, that gets translated to javascript:
http://github.com/certik/notebook/blob/ef396ef2eb3314ff787000cac7e34b1c08d9af6a/media/index.py
It's all pure python and with pyjamas desktop it should be possible to
run it on the desktop, e.g. in a python interpreter. I think in the
long term, this is the way to go.
Pyjamas is still developing, e.g. I contributed the initial urllib
package into it (the index.py file above still contains my older hack,
that calls javascript --- with new pyjamas, this is not needed
anymore), etc.
Anyway, I am looking forward, I think in couple years it will be
absolutely common thing to have sophisticated web applications and we
could write them in Python.
Ondrej
Hi,
so I fixed most of the early bugs, here is my latest attempt:
http://4.latest.pythonnb.appspot.com/
it seems to be working reasonably well in most browsers I tried (FF,
IE, Safari, Opera, Chrome, ...).
Opera can't handle event.preventDefault(), which means that if you
press shift+enter, the enter will still get propagated and the new
cell will have 2 rows. I think it's a bug in Opera, but maybe there is
some fix for this. All other browsers seem to work for me.
It's not as polished as my original javascript version:
http://pythonnb.appspot.com/
e.g. the evaluate button is not there, and the blue line is not there
yet either, neither is the blue focus rectangle around cells. I will
not have time for the next month or so to work on this, but I am now
confident that it can be done.
Look at the code here, that gets translated to javascript:
http://github.com/certik/notebook/blob/ef396ef2eb3314ff787000cac7e34b1c08d9af6a/media/index.py
It's all pure python and with pyjamas desktop it should be possible to
run it on the desktop, e.g. in a python interpreter. I think in the
long term, this is the way to go.
Pyjamas is still developing, e.g. I contributed the initial urllib
package into it (the index.py file above still contains my older hack,
that calls javascript --- with new pyjamas, this is not needed
anymore), etc.
Anyway, I am looking forward, I think in couple years it will be
absolutely common thing to have sophisticated web applications and we
could write them in Python.
It's because in pyjamas I am using some pyjamas widget (I think
RootPanel) that adds <div> after each element, thus the spacing gets
wrong. To fix this, one just has to persuade pyjamas not to put any
<div> in the html output and then it should be ok.
But all these CSS style things always take me couple hours to fix, so
I'll just leave it as is. It convinced me that it can be done, so
that's all I wanted to know.
>
>>
>> Look at the code here, that gets translated to javascript:
>>
>>
>> http://github.com/certik/notebook/blob/ef396ef2eb3314ff787000cac7e34b1c08d9af6a/media/index.py
>>
>> It's all pure python and with pyjamas desktop it should be possible to
>> run it on the desktop, e.g. in a python interpreter. I think in the
>> long term, this is the way to go.
>>
>> Pyjamas is still developing, e.g. I contributed the initial urllib
>> package into it (the index.py file above still contains my older hack,
>> that calls javascript --- with new pyjamas, this is not needed
>> anymore), etc.
>>
>> Anyway, I am looking forward, I think in couple years it will be
>> absolutely common thing to have sophisticated web applications and we
>> could write them in Python.
>
> Nice. I have to say honestly that the idea of using pyjamas is the only
> thing I've ever seen that made me personally have that feeling "I want to
> rewrite the javascript part of the notebook". I'm really glad you did a
> prototype of this so we could see what some of the issues are.
I forgot how I got the idea to rewrite it, I think I just wanted to
learn AJAX, so the best thing to learn it is to write it myself from
scratch.
But if I am going to write some new webapp from scratch, I am going to
use pyjamas. For Sage notebook though, we may just continue improving
the current one, as I am not much a fan of rewriting applications from
scratch.
Ondrej
Yep. There are things that I now don't like on the Sage notebook, like
that if I click on a cell, the frame gets focused (that's ok), but the
text moves by one pixel. I hate that. My javascript version doesn't do
that, at least on firefox. In fact, it's just a CSS styles issue, so
it's easy to fix -- but I wasn't sure if it's just on my firefox, or
everywhere.
Also, it seems to me the reaction to keys is a bit slow in the cells,
if I press enter, the cursor first moves half way out of the cell and
only then (maybe 0.1s) the cell gets resized. I hate that too, but I
think my javascript version works better in this particular case, so
we may just use my approach here, if it works everywhere.
Then just today I had to modify the notebook on about 5 places to
change the executable to be called:
http://github.com/certik/femhub_notebook/commit/4db3c0108ab4f8e44077899d879b8f1bd1927526
so there should be some variable for that. Things like that, I think
those are best fixed by improving the current notebook rather than
rewriting it.
Ondrej
Also, it seems to me the reaction to keys is a bit slow in the cells,
if I press enter, the cursor first moves half way out of the cell and
only then (maybe 0.1s) the cell gets resized. I hate that too, but I
think my javascript version works better in this particular case, so
we may just use my approach here, if it works everywhere.
Then just today I had to modify the notebook on about 5 places to
change the executable to be called:
http://github.com/certik/femhub_notebook/commit/4db3c0108ab4f8e44077899d879b8f1bd1927526
so there should be some variable for that. Things like that, I think
those are best fixed by improving the current notebook rather than
rewriting it.
I just found out that the new py.test and its plugin here (released today):
http://pypi.python.org/pypi/oejskit
can test javascript in the real browser against a python server. So I
would go that way for testing the javascript.
Ondrej