Show More
@@ -171,7 +171,7 b' def interactive(__interact_f, **kwargs):' | |||
|
171 | 171 | Parameters |
|
172 | 172 | ---------- |
|
173 | 173 | __interact_f : function |
|
174 | The function to which the interactive widgets are tied. The **kwargs | |
|
174 | The function to which the interactive widgets are tied. The `**kwargs` | |
|
175 | 175 | should match the function signature. |
|
176 | 176 | **kwargs : various, optional |
|
177 | 177 | An interactive widget is created for each keyword argument that is a |
@@ -246,7 +246,7 b' def interact(__interact_f=None, **kwargs):' | |||
|
246 | 246 | """ |
|
247 | 247 | Displays interactive widgets which are tied to a function. |
|
248 | 248 | Expects the first argument to be a function. Parameters to this function are |
|
249 | widget abbreviations passed in as keyword arguments (**kwargs). Can be used | |
|
249 | widget abbreviations passed in as keyword arguments (`**kwargs`). Can be used | |
|
250 | 250 | as a decorator (see examples). |
|
251 | 251 | |
|
252 | 252 | Returns |
@@ -256,7 +256,7 b' def interact(__interact_f=None, **kwargs):' | |||
|
256 | 256 | Parameters |
|
257 | 257 | ---------- |
|
258 | 258 | __interact_f : function |
|
259 | The function to which the interactive widgets are tied. The **kwargs | |
|
259 | The function to which the interactive widgets are tied. The `**kwargs` | |
|
260 | 260 | should match the function signature. Passed to :func:`interactive()` |
|
261 | 261 | **kwargs : various, optional |
|
262 | 262 | An interactive widget is created for each keyword argument that is a |
@@ -264,37 +264,37 b' def interact(__interact_f=None, **kwargs):' | |||
|
264 | 264 | |
|
265 | 265 | Examples |
|
266 | 266 | -------- |
|
267 |
Render |
|
|
268 |
text |
|
|
267 | Render an interactive text field that shows the greeting with the passed in | |
|
268 | text:: | |
|
269 | 269 | |
|
270 |
|
|
|
270 | # 1. Using interact as a function | |
|
271 | 271 | def greeting(text="World"): |
|
272 | 272 | print "Hello {}".format(text) |
|
273 | 273 | interact(greeting, text="IPython Widgets") |
|
274 | 274 | |
|
275 |
|
|
|
275 | # 2. Using interact as a decorator | |
|
276 | 276 | @interact |
|
277 | 277 | def greeting(text="World"): |
|
278 | 278 | print "Hello {}".format(text) |
|
279 | 279 | |
|
280 |
|
|
|
280 | # 3. Using interact as a decorator with named parameters | |
|
281 | 281 | @interact(text="IPython Widgets") |
|
282 | 282 | def greeting(text="World"): |
|
283 | 283 | print "Hello {}".format(text) |
|
284 | 284 | |
|
285 |
Render |
|
|
285 | Render an interactive slider widget and prints square of number:: | |
|
286 | 286 | |
|
287 |
|
|
|
287 | # 1. Using interact as a function | |
|
288 | 288 | def square(num=1): |
|
289 | 289 | print "{} squared is {}".format(num, num*num) |
|
290 | 290 | interact(square, num=5) |
|
291 | 291 | |
|
292 |
|
|
|
292 | # 2. Using interact as a decorator | |
|
293 | 293 | @interact |
|
294 | 294 | def square(num=2): |
|
295 | 295 | print "{} squared is {}".format(num, num*num) |
|
296 | 296 | |
|
297 |
|
|
|
297 | # 3. Using interact as a decorator with named parameters | |
|
298 | 298 | @interact(num=5) |
|
299 | 299 | def square(num=2): |
|
300 | 300 | print "{} squared is {}".format(num, num*num) |
General Comments 0
You need to be logged in to leave comments.
Login now