##// END OF EJS Templates
Notification + tooltip demo...
Matthias BUSSONNIER -
Show More
@@ -123,9 +123,18 b' var IPython = (function (IPython) {'
123 this.tooltip.append(this.text);
123 this.tooltip.append(this.text);
124
124
125 // function that will be called if you press tab 1, 2, 3... times in a row
125 // function that will be called if you press tab 1, 2, 3... times in a row
126 this.tabs_functions = [ function(cell,text){that._request_tooltip(cell,text)},
126 this.tabs_functions = [ function(cell,text){
127 function(){that.expand()},
127 that._request_tooltip(cell,text);
128 function(){that.stick()},
128 IPython.notification_widget.set_message('tab again to expand pager',2500);
129 },
130 function(){
131 that.expand();
132 IPython.notification_widget.set_message('tab again to make pager sticky for 10s',2500);
133 },
134 function(){
135 that.stick();
136 IPython.notification_widget.set_message('tab again to open help in pager',2500);
137 },
129 function(cell){
138 function(cell){
130 that.cancel_stick();
139 that.cancel_stick();
131 that.showInPager(cell);
140 that.showInPager(cell);
@@ -35,7 +35,6 b''
35 },
35 },
36 {
36 {
37 "cell_type": "code",
37 "cell_type": "code",
38 "collapsed": false,
39 "input": [
38 "input": [
40 "\"This is the new IPython notebook\""
39 "\"This is the new IPython notebook\""
41 ],
40 ],
@@ -66,7 +65,6 b''
66 },
65 },
67 {
66 {
68 "cell_type": "code",
67 "cell_type": "code",
69 "collapsed": false,
70 "input": [
68 "input": [
71 "ls"
69 "ls"
72 ],
70 ],
@@ -93,7 +91,6 b''
93 },
91 },
94 {
92 {
95 "cell_type": "code",
93 "cell_type": "code",
96 "collapsed": false,
97 "input": [
94 "input": [
98 "def f(x):",
95 "def f(x):",
99 " \"\"\"My function",
96 " \"\"\"My function",
@@ -180,10 +177,7 b''
180 "closely related to IPython as well as the minimal keybindings you need to",
177 "closely related to IPython as well as the minimal keybindings you need to",
181 "know. But you should use `Ctrl-m h` (or click the `QuickHelp` button at",
178 "know. But you should use `Ctrl-m h` (or click the `QuickHelp` button at",
182 "the top) and learn some of the other keybindings, as it will make your ",
179 "the top) and learn some of the other keybindings, as it will make your ",
183 "workflow much more fluid and efficient.",
180 "workflow much more fluid and efficient."
184 "",
185 "The *Configuration* section at the bottom lets you change some values",
186 "related to the display of tooltips and the behavior of the tab completer."
187 ]
181 ]
188 },
182 },
189 {
183 {
@@ -231,10 +225,9 b''
231 },
225 },
232 {
226 {
233 "cell_type": "code",
227 "cell_type": "code",
234 "collapsed": true,
235 "input": [
228 "input": [
236 "# Position your cursor after the ( and hit the Tab key:",
229 "# Position your cursor after the ( and hit the Tab key:",
237 "list("
230 "range("
238 ],
231 ],
239 "language": "python",
232 "language": "python",
240 "outputs": []
233 "outputs": []
@@ -242,6 +235,77 b''
242 {
235 {
243 "cell_type": "markdown",
236 "cell_type": "markdown",
244 "source": [
237 "source": [
238 "More over pressing tab several time in a row allows you change the behaviour of the tooltip.",
239 "",
240 "* firt `tab` press, you get a classical tooltip",
241 "* second time, the tooltip grow vertically, and allow you to scroll the docstring",
242 "* third tab press, tooltip, will be made sticky for 10 seconds, allowing you to carry on typing while it stays open.",
243 "* forth time press, the tooltip help is sent to the pager at the bottom of the screen , and is dismiss.",
244 "<script>",
245 " IPython.tooltip.tabs_functions = [ function(cell,text){",
246 " IPython.tooltip._request_tooltip(cell,text);",
247 " IPython.notification_widget.set_message('tab again to expand pager',2500);",
248 " setTimeout(function(){",
249 " $('.tooltiptext pre').text(\"function signture : You've invoked a tooltip !\\n\\nWell done! Here usualy lies the current function *call signature* and it's *docstring*. You can now expand the tooltip pressing <tab> a second time...\")},400);",
250 " },",
251 " function(){",
252 " IPython.tooltip.expand();",
253 " IPython.notification_widget.set_message('tab again to make pager sticky for 10s',2500);",
254 " setTimeout(function(){",
255 " $('.tooltiptext pre').text(\"Now the tooltip is expanded !\\",
256 " \\n\\nThis is really usefull if you have long docstring and if you want to be able to scroll them. \\",
257 "For example, I can give you many information about the tooltip:\\n - The tooltip is smart, and \\",
258 "you don't always need to press tab to invoke it, if you press an opening bracket `(` then nothing \\",
259 "for some time, tooltip will be invoked by itself.\\",
260 "\\n - Also you can hoover over the icon on the top right to know what they are dooing...\\",
261 "\\n\\nBack to the next lesson.\\n\\nSometime you need to the tooltip to stay on screen while\\",
262 "you type. That's the reason for the sticky mode (indicated by a small clock on the top left of the tooltip),\\",
263 "\\n\\nNow press <tab> a 3rd time and continue typing some text to test it...\")",
264 " },400);",
265 " },",
266 " function(){",
267 " var time = 35;",
268 " IPython.tooltip.stick(time);",
269 " $('.tooltiptext pre').text(\"Type more text !...\\n\\n range(7,125,3)\\n\\n The tooltip is in sticky mode, it won't be dismissed for at least 10 secondes \",400);",
270 " setTimeout(function(){",
271 " $('.tooltiptext pre').text(\"That was sticky mode...\\nI'll keep it on 15 more seconds just for you.\\n\\nLast thing you can do is send the current help displayed in the tooltip to the pager at the bottom of the screen. To do that, press tab 4 time in a row after a parenthesis. \\n\\n Now I'll stop bothering you and let you Play with the tooltip !\");",
272 " reset_tooltip()",
273 " },15000);",
274 " },",
275 " function(cell){",
276 " IPython.tooltip.cancel_stick();",
277 " reset_tooltip()",
278 " IPython.tooltip.showInPager(cell);",
279 " IPython.tooltip._cmfocus();",
280 " }",
281 " ];",
282 " ",
283 " reset_tooltip = function(){",
284 " IPython.tooltip.tabs_functions = [ function(cell,text){",
285 " IPython.tooltip._request_tooltip(cell,text);",
286 " IPython.notification_widget.set_message('tab again to expand pager',2500);",
287 " },",
288 " function(){",
289 " IPython.tooltip.expand();",
290 " IPython.notification_widget.set_message('tab again to make pager sticky for 10s',2500);",
291 " },",
292 " function(){",
293 " IPython.tooltip.stick();",
294 " IPython.notification_widget.set_message('tab again to open help in pager',2500);",
295 " },",
296 " function(cell){",
297 " IPython.tooltip.cancel_stick();",
298 " IPython.tooltip.showInPager(cell);",
299 " IPython.tooltip._cmfocus();",
300 " }",
301 " ];",
302 " }",
303 "</script>"
304 ]
305 },
306 {
307 "cell_type": "markdown",
308 "source": [
245 "## The frontend/kernel model",
309 "## The frontend/kernel model",
246 "",
310 "",
247 "The IPython notebook works on a client/server model where an *IPython kernel*",
311 "The IPython notebook works on a client/server model where an *IPython kernel*",
@@ -265,7 +329,6 b''
265 },
329 },
266 {
330 {
267 "cell_type": "code",
331 "cell_type": "code",
268 "collapsed": false,
269 "input": [
332 "input": [
270 "%connect_info"
333 "%connect_info"
271 ],
334 ],
@@ -347,7 +410,6 b''
347 },
410 },
348 {
411 {
349 "cell_type": "code",
412 "cell_type": "code",
350 "collapsed": false,
351 "input": [
413 "input": [
352 "%pylab inline",
414 "%pylab inline",
353 "plot(rand(100))"
415 "plot(rand(100))"
@@ -408,8 +470,9 b''
408 },
470 },
409 {
471 {
410 "cell_type": "code",
472 "cell_type": "code",
411 "collapsed": true,
473 "input": [
412 "input": [],
474 ""
475 ],
413 "language": "python",
476 "language": "python",
414 "outputs": []
477 "outputs": []
415 }
478 }
General Comments 0
You need to be logged in to leave comments. Login now