Show More
@@ -1,3 +1,5 b'' | |||
|
1 | import os | |
|
2 | ||
|
1 | 3 | # System library imports |
|
2 | 4 | from PyQt4 import QtCore, QtGui |
|
3 | 5 | |
@@ -61,7 +63,7 b' class RichIPythonWidget(IPythonWidget):' | |||
|
61 | 63 | """ |
|
62 | 64 | payload = msg['content']['payload'] |
|
63 | 65 | for item in payload: |
|
64 | if item['type'] == 'plot': | |
|
66 | if item['source'] == 'IPython.zmq.pylab.backend_payload.add_plot_payload': | |
|
65 | 67 | if item['format'] == 'svg': |
|
66 | 68 | svg = item['data'] |
|
67 | 69 | try: |
@@ -78,6 +80,24 b' class RichIPythonWidget(IPythonWidget):' | |||
|
78 | 80 | else: |
|
79 | 81 | # Add other plot formats here! |
|
80 | 82 | pass |
|
83 | elif item['source'] == 'IPython.zmq.zmqshell.ZMQInteractiveShell.edit_magic': | |
|
84 | # TODO: I have implmented the logic for TextMate on the Mac. | |
|
85 | # But, we need to allow payload handlers on the non-rich | |
|
86 | # text IPython widget as well. Furthermore, we should probably | |
|
87 | # move these handlers to separate methods. But, we need to | |
|
88 | # be very careful to process the payload list in order. Thus, | |
|
89 | # we will probably need a _handle_payload method of the | |
|
90 | # base class that dispatches to the separate handler methods | |
|
91 | # for each payload source. If a particular subclass doesn't | |
|
92 | # have a handler for a payload source, it should at least | |
|
93 | # print a nice message. | |
|
94 | filename = item['filename'] | |
|
95 | line_number = item['line_number'] | |
|
96 | if line_number is None: | |
|
97 | cmd = 'mate %s' % filename | |
|
98 | else: | |
|
99 | cmd = 'mate -l %s %s' % (line_number, filename) | |
|
100 | os.system(cmd) | |
|
81 | 101 | else: |
|
82 | 102 | # Add other payload types here! |
|
83 | 103 | pass |
@@ -19,5 +19,8 b' def add_plot_payload(format, data, metadata={}):' | |||
|
19 | 19 | metadata : dict, optional [default empty] |
|
20 | 20 | Allows for specification of additional information about the plot data. |
|
21 | 21 | """ |
|
22 | payload = dict(type='plot', format=format, data=data, metadata=metadata) | |
|
22 | payload = dict( | |
|
23 | source='IPython.zmq.pylab.backend_payload.add_plot_payload', | |
|
24 | format=format, data=data, metadata=metadata | |
|
25 | ) | |
|
23 | 26 | InteractiveShell.instance().payload_manager.write_payload(payload) |
@@ -1,3 +1,5 b'' | |||
|
1 | import inspect | |
|
2 | import re | |
|
1 | 3 | import sys |
|
2 | 4 | from subprocess import Popen, PIPE |
|
3 | 5 | |
@@ -5,7 +7,11 b' from IPython.core.interactiveshell import (' | |||
|
5 | 7 | InteractiveShell, InteractiveShellABC |
|
6 | 8 | ) |
|
7 | 9 | from IPython.core.displayhook import DisplayHook |
|
10 | from IPython.core.macro import Macro | |
|
11 | from IPython.utils.path import get_py_filename | |
|
12 | from IPython.utils.text import StringTypes | |
|
8 | 13 | from IPython.utils.traitlets import Instance, Type, Dict |
|
14 | from IPython.utils.warn import warn | |
|
9 | 15 | from IPython.zmq.session import extract_header |
|
10 | 16 | |
|
11 | 17 | |
@@ -341,43 +347,6 b' class ZMQInteractiveShell(InteractiveShell):' | |||
|
341 | 347 | } |
|
342 | 348 | self.payload_manager.write_payload(payload) |
|
343 | 349 | |
|
344 | # # do actual editing here | |
|
345 | # print 'Editing...', | |
|
346 | # sys.stdout.flush() | |
|
347 | # try: | |
|
348 | # # Quote filenames that may have spaces in them | |
|
349 | # if ' ' in filename: | |
|
350 | # filename = "%s" % filename | |
|
351 | # self.shell.hooks.editor(filename,lineno) | |
|
352 | # except TryNext: | |
|
353 | # warn('Could not open editor') | |
|
354 | # return | |
|
355 | # | |
|
356 | # # XXX TODO: should this be generalized for all string vars? | |
|
357 | # # For now, this is special-cased to blocks created by cpaste | |
|
358 | # if args.strip() == 'pasted_block': | |
|
359 | # self.shell.user_ns['pasted_block'] = file_read(filename) | |
|
360 | # | |
|
361 | # if opts.has_key('x'): # -x prevents actual execution | |
|
362 | ||
|
363 | # else: | |
|
364 | # print 'done. Executing edited code...' | |
|
365 | # if opts_r: | |
|
366 | # self.shell.runlines(file_read(filename)) | |
|
367 | # else: | |
|
368 | # self.shell.safe_execfile(filename,self.shell.user_ns, | |
|
369 | # self.shell.user_ns) | |
|
370 | # | |
|
371 | # | |
|
372 | # if use_temp: | |
|
373 | # try: | |
|
374 | # return open(filename).read() | |
|
375 | # except IOError,msg: | |
|
376 | # if msg.filename == filename: | |
|
377 | # warn('File not found. Did you forget to save?') | |
|
378 | # return | |
|
379 | # else: | |
|
380 | # self.shell.showtraceback() | |
|
381 | 350 | |
|
382 | 351 | InteractiveShellABC.register(ZMQInteractiveShell) |
|
383 | 352 |
General Comments 0
You need to be logged in to leave comments.
Login now