Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Tooltip, New Completer and JS Refactor #1711

Merged
merged 84 commits into from Jun 1, 2012
Merged

Conversation

Carreau
Copy link
Member

@Carreau Carreau commented May 7, 2012

On request of @ellisonbg, I pushed a branch that regroups 2 others PR : #1509 (New tooltip and Completer) #1697 (JS refactor) that were conflicting and both changing some logic.

This makes the 2 compatible and working... It still need some spring cleaning to be sure there is no orphan methods, useless code or simplification possible due to new JS refactoring.

@ellisonbg
Copy link
Member

OK thanks for creating this branch. I am going to be working in it directly over the next few days.

@Carreau Carreau mentioned this pull request May 8, 2012
@ellisonbg
Copy link
Member

@Carreau how do you want to work on this branch so we don't step on each other. I could spend a day or so working on my parts and reviewing your and then you could work on yours. How does that sound?

@Carreau
Copy link
Member Author

Carreau commented May 8, 2012

@ellisonbg, I can also push on my repository and send you PRs.
Eventually rebasing before pushing on ipython.
In any case I push some commit in a few minutes, and after I'm almost done (for now) on my part.
And if you need I'm syncin my computers through https://github.com/Carreau/ipython/tree/tooltipCompleterJSRefactor

@ellisonbg
Copy link
Member

Please let me know when you have pushed your changes so I can start to
work on the repo. After that, let's have you submit PRs against it.

On Tue, May 8, 2012 at 10:11 AM, Bussonnier Matthias
reply@reply.github.com
wrote:

@ellisonbg, I can also push on my repository and send you PRs.
Eventually rebasing before pushing on ipython.
In any case I push some commit in a few minutes, and after I'm almost done (for now) on my part.
And if you need I'm syncin my computers through https://github.com/Carreau/ipython/tree/tooltipCompleterJSRefactor


Reply to this email directly or view it on GitHub:
#1711 (comment)

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

@Carreau
Copy link
Member Author

Carreau commented May 8, 2012

Pushed 2h ago. Sorry, it starting to be late here, won't work on it for at least 18h.
I'll make my next change by PR.

@ellisonbg
Copy link
Member

Awesome thanks for your work!

On Tue, May 8, 2012 at 11:59 AM, Bussonnier Matthias
reply@reply.github.com
wrote:

Pushed 2h ago. Sorry, it starting to be late here, won't work on it for at least 18h.
I'll make my next change by PR.


Reply to this email directly or view it on GitHub:
#1711 (comment)

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

@Carreau
Copy link
Member Author

Carreau commented May 8, 2012

Thanks to you for the new JS interface to communicate with the kernel, it's great, and for all the notebook in general.
When I'll have time later I'll try to comment/document more what I've done.

@ellisonbg
Copy link
Member

@minrk, OK I have added the options to Kernel.execute with silent=true the default. I have tested your callbacks notebook and it no longer increments the prompt number so it is working properly. Oh and BTW, I love the callbacks notebook!

// callbacks = {
// 'complete_reply': complete_reply_callback
// }
//
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering, as there is only one argument for the callbacks, could we not directly build it ourself and use complete_reply_callback as an argument of the function ? We can even support both by looking at wether the third argument given to the function has a complete_reply key or not...

Same for object_info_request I think

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason that I went with this is that JavaScript doesn't support
optional keyword arguments. So for functions like execute that take
multiple optional callbacks, there really isn't a way to do something
like:

def execute(code, execute_reply=None, cell=None, output=None, ...)

Some of the other methods doesn't need multiple callbacks, but I
wanted to make a uniform interface, so I went with a callback struct.

On Wed, May 9, 2012 at 9:02 AM, Bussonnier Matthias
reply@reply.github.com
wrote:

         return msg.header.msg_id;
     };

  •    Kernel.prototype.complete = function (line, cursor_pos) {
  •    Kernel.prototype.complete = function (line, cursor_pos, callbacks) {
  •        // When calling this method pass a callbacks structure of the form:
  •        //
  •        // callbacks = {
  •        //  'complete_reply': complete_reply_callback
  •        // }
  •        //

I was wondering, as there is only one argument for the callbacks, could we not directly build it ourself and use complete_reply_callback as an argument of the function ? We can even support both by looking at wether the third argument given to the function has a complete_reply key or not...

Same  for object_info_request I think


Reply to this email directly or view it on GitHub:
https://github.com/ipython/ipython/pull/1711/files#r795774

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

@ellisonbg
Copy link
Member

@Carreau some feedback on the tooltip:

First, some related to the visual consistency:

  • I think the tooltip needs to have a solid (non-gradient) background. Reading text on a gradient bg is visually distracting. We should find a neutral solid color that matches our theming.
  • The amount of corner rounding on the tooltip popup is too much given how other elements have their corners rounded. We should use something closer to what the rest of our page has.
  • The shadow of the tooltip should more closely match that used by the menus in the menu bar.
  • The small icons in the upper right corner have a right padding of 15 px. This should be reduced a small amount.

Some related to the different modes:

  • I don't understand what the third mode is when the clock/watch appears. It doesn't look any different from the 2nd mode. Can you clarify.
  • You used to be able to open the help in the pager by pressing tab another time. That seems to have gone away.
  • I think having a simpler model with only 3 modes might make sense: 1) default small mode 2) expanded mode 3) pager mode.

@Carreau
Copy link
Member Author

Carreau commented May 9, 2012

First, some related to the visual consistency:

I think the tooltip needs to have a solid (non-gradient) background. Reading text on a gradient bg is visually distracting. We should find a neutral solid color that matches our theming.
The amount of corner rounding on the tooltip popup is too much given how other elements have their corners rounded. We should use something closer to what the rest of our page has.
The shadow of the tooltip should more closely match that used by the menus in the menu bar.

Changed, cf screenshot

The small icons in the upper right corner have a right padding of 15 px. This should be reduced a small amount.
Some related to the different modes:

Tested on Chrome or safari osx I guess... on firefox and other OS you get a scrollbar in those 15 pixels if the text is longer than the pager
15px and scrollbar

The scroll bar is hidden when tooltip is not expanded so I can remove those 15px then, but I have to add them it is expanded, otherwise it overlaps and clicking on the 'cross+scrollbar' get weird and have unexpected behaviour. I havent found any good ways to 'detect' the scrollbar.

I don't understand what the third mode is when the clock/watch appears. It doesn't look any different from the 2nd mode. Can you clarify.

Sure, when the clock is there you can continue typing and the pager don't dismiss for 10s (I call it sticky mode)

plot(<tab><tab><tab> I can continue typing and plot docstring stays for 10s

Unless of course, I ask for tooltip on another function.

You used to be able to open the help in the pager by pressing tab another time. That seems to have gone away.
That's strange indead, i'll fix it, it should be 4 tab press...

I think having a simpler model with only 3 modes might make sense: 1) default small mode 2) expanded mode 3) pager mode.

So do I keep "sticky mode" and "15px" ?

@Carreau
Copy link
Member Author

Carreau commented May 9, 2012

Pager problem updated on my branch with same name as this one.

@ellisonbg
Copy link
Member

On Wed, May 9, 2012 at 11:13 AM, Bussonnier Matthias
reply@reply.github.com
wrote:

First, some related to the visual consistency:

I think the tooltip needs to have a solid (non-gradient) background. Reading text on a gradient bg is visually distracting. We should find a neutral solid color that matches our theming.
The amount of corner rounding on the tooltip popup is too much given how other elements have their corners rounded. We should use something closer to what the rest of our page has.
The shadow of the tooltip should more closely match that used by the menus in the menu bar.

Changed, cf screenshot

Great, I like this look much better.

The small icons in the upper right corner have a right padding of 15 px. This should be reduced a small amount.
Some related to the different modes:

Tested on Chrome or safari osx I guess...  on firefox  and other OS you get a scrollbar in those 15 pixels if the text is longer than the pager
15px and scrollbar

The scroll bar is hidden when tooltip is not expanded so I can remove those 15px then, but I have to add them it is expanded, otherwise it overlaps and clicking on the 'cross+scrollbar' get weird and have unexpected behaviour. I havent found any good ways to 'detect' the scrollbar.

Ahh, I see then leave it as is.

I don't understand what the third mode is when the clock/watch appears. It doesn't look any different from the 2nd mode. Can you clarify.

Sure, when the clock is there you can continue typing and the pager don't dismiss for 10s (I call it sticky mode)

Ahh, OK is there a way we could indicate to the user what the
different modes mean. I mean the most verbose thing would be to add
text at the top saying "press tab again to expand", "press tab again
to make sticky" and "press tab again to open in pager" But that is
probably a bit verbose.

plot(<tab><tab><tab> I can continue typing and plot docstring stays for 10s

Unless of course, I ask for tooltip on another function.

You used to be able to open the help in the pager by pressing tab another time. That seems to have gone away.
That's strange indead, i'll fix it, it should be 4 tab press...

OK great.

I think having a simpler model with only 3 modes might make sense: 1) default small mode 2) expanded mode 3) pager mode.

So do I keep "sticky mode" and "15px" ?

Yes, I think so, unless we wanted to make sticky mode on by default.
But I think it is a reasonable thing. It would be nice if we could
guide the user a bit more though.


Reply to this email directly or view it on GitHub:
#1711 (comment)

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

@ellisonbg
Copy link
Member

OK I tested out your branch and the tooltip looks pretty good. The behavior is pretty smooth and intuitive and the visual look is clean. When you are ready, can you submit a PR against this branch and I will merge it in. I will have further comments coming though.

@tkf
Copy link
Contributor

tkf commented May 9, 2012

Also, please check Notebook.prototype.toJSON. It has variable a data w/o var.

* have some strange ccs to have the scroll bar on
* the left of the left with fix button on the top right of the tooltip
*/
@-moz-keyframes fadeOut {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jQuery/jQueryUI have the ability to animate css properties, can we use that instead of this css? I think it will give us better cross browser coverage. If you don't think it makes sense that is fine, but at least look at it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well when supported css3 is native, so much faster and less load on JS VM. And as tooltip fading is not that important I thought it was a good trade not o have it if not supported... I can try with jquery

Carreau and others added 25 commits May 31, 2012 13:08
For security reasons, the kernel should not be started until
after the notebook content is completely loaded and on the page.
This prevents people from creating notebooks that run nasty code
on the users machine at load time.

In order to implement this, we had to create a CodeCell.set_kernel
method that allows the kernel attribute of a CodeCell to be set
at a later time.  This also fixes some error messages we were
seeing related to the kernel's channels not being setup properly
when a send was attempted.
it seem that show and hide methods fron tooltip where collinding with
jquery, sometime blocking the notebook.

Move from css fadeIn/Out to jQuery fade In/Out, and replace
addRemoveClass by fadeIn/fadeOut
check that the cell the tooltip is giving focus back is the currently
selected cell
When kernel is died and restarted, or restarted while it is in the
busy state, message "(Busy)" on the window title is not updated.  This
problem is fixed by updating document title when restarting.
This allows code outside notebook.js to set the dirty flag, but
doesn't require that code depend on notebook.js.
@ellisonbg
Copy link
Member

OK, I have done everything talked about in this review. I think it is ready for merging - this a huge, long-lived branch that should get merged sooner rather than later. Please let me know if you see anything else that needs work.

@fperez
Copy link
Member

fperez commented Jun 1, 2012

OK, I'm merging this: at this point, delaying it any further only increases the risk of nasty conflicts, and we're hitting the point of diminishing returns. We can always (and we will) keep improving after it's merged.

A huge thank you and kudos to @Carreau and @ellisonbg for the amount of effort you guys put into this, and for the great teamwork here. Thanks also to @tkf and everyone else who pitched in with code, feedback, etc. It's a real pleasure to work on a project with a team like this.

On to the widgets!!!!!!!!!!

fperez added a commit that referenced this pull request Jun 1, 2012
New Tooltip, New Completer and JS Refactor.

This is a major reworking of lots of notebook client code, both introducing new features and allowing certain things to be done more cleanly:

- New graphical tooltip with keyboard control: successive presses of the TAB key will expand it, pin it for 10 s (a clock icon is shown), and send its content to the bottom help pager (which is now resizable).

- Completer has been refactored into a new class and now can analyze the current cell to support completions on objects that don't exist in the kernel yet (because the cell hasn't been executed).

- All the client-side JavaScript has been decoupled to ease reuse of parts of the machinery without having to build a full-blown notebook. This will make it much easier to communicate with an IPython kernel from existing web pages and to integrate single cells into other sites, without loading the full notebook document-like UI.

- This refactoring also enables the possibility of writing dynamic javascript widgets that are returned from Python code and that present an interactive view to the user, with callbacks in Javascript executing calls to the Kernel.  This will enable many interactive elements to be added by users in notebooks.  

An example of this capability has been provided as a proof of concept in `docs/examples/widgets` that lets you directly communicate with one or more parallel engines, acting as a mini-console for parallel debugging and introspection.

Closes #1498.
@fperez fperez merged commit 3d3a488 into master Jun 1, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
New Tooltip, New Completer and JS Refactor.

This is a major reworking of lots of notebook client code, both introducing new features and allowing certain things to be done more cleanly:

- New graphical tooltip with keyboard control: successive presses of the TAB key will expand it, pin it for 10 s (a clock icon is shown), and send its content to the bottom help pager (which is now resizable).

- Completer has been refactored into a new class and now can analyze the current cell to support completions on objects that don't exist in the kernel yet (because the cell hasn't been executed).

- All the client-side JavaScript has been decoupled to ease reuse of parts of the machinery without having to build a full-blown notebook. This will make it much easier to communicate with an IPython kernel from existing web pages and to integrate single cells into other sites, without loading the full notebook document-like UI.

- This refactoring also enables the possibility of writing dynamic javascript widgets that are returned from Python code and that present an interactive view to the user, with callbacks in Javascript executing calls to the Kernel.  This will enable many interactive elements to be added by users in notebooks.  

An example of this capability has been provided as a proof of concept in `docs/examples/widgets` that lets you directly communicate with one or more parallel engines, acting as a mini-console for parallel debugging and introspection.

Closes ipython#1498.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants