Commits

Matthew Turk committed 93b21ff

load_script and deliver_image work again.

  • Participants
  • Parent commits 3bad7bd

Comments (0)

Files changed (5)

File yt/gui/reason/extdirect_repl.py

                 {'type': 'cell',
                  'output': result,
                  'input': highlighter(code),
+                 'image_data': '',
                  'raw_input': code},
                 )
         objs = get_list_of_datasets()
 
 
 def reason_pylab():
+    from .utils import deliver_image
     def _canvas_deliver(canvas):
         tf = tempfile.TemporaryFile()
         canvas.print_png(tf)

File yt/gui/reason/html/app/controller/Notebook.js

     init: function() {
         this.application.addListener({
             payloadcell: {fn: this.addCell, scope: this},
+            payloadscript: {fn: this.loadScript, scope: this},
             executecell: {fn: this.executeCell, scope: this},
             wipeinput:   {fn: this.wipeInputLine, scope: this},
             blockinput:  {fn: this.blockInput, scope: this},
             input: cell['input'],
             output: cell['output'],
             raw_input: cell['raw_input'],
+            image_data: cell['image_data'],
             executiontime: cell['executiontime'],
         });
         this.application.fireEvent("scrolltobottom");
     },
+
+    loadScript: function(payload) {
+        console.log("Loading script ...");
+        this.getInputLine().setValue(payload['value']);
+        this.getInputLine()._lock = true;
+    },
+
     executeCell: function(line) {
         this.application.fireEvent("blockinput");
         console.log("Asked to execute " + line);
     },
     
     wipeInputLine: function() {
-        this.getInputLine().setValue("");
+        if(this.getInputLine()._lock == true) {
+            this.getInputLine()._lock = false;
+        } else {
+            this.getInputLine().setValue("");
+        }
     },
 
     blockInput: function() {

File yt/gui/reason/html/app/store/CellValues.js

 Ext.define('Reason.store.CellValues', {
     extend: 'Ext.data.Store',
     id: 'cellvalues',
-    fields: ['input', 'output', 'raw_input', 'executiontime'],
+    fields: ['input', 'output', 'raw_input', 'executiontime', 
+        { name: 'image_data', type: 'string', defaultValue: '' }
+    ],
     data: [],
 });
 

File yt/gui/reason/html/app/view/CellView.js

     '<pre>{output}</pre><br/><br/>'
 );
 
+var imageDisplay = new Ext.XTemplate(
+    '<b>Image</b><br/><br/>',
+    '<hr>',
+    '<img src="data:image/png;base64,{image_data}">',
+    '<br/><br/>'
+);
+
 Ext.define('Reason.view.CellView', {
     extend: 'Ext.grid.Panel',
     alias: 'widget.notebookcells',
     features: [{
         ftype: 'rowbody',
         getAdditionalData: function(data, rowIndex, record, orig) {
+            var disp;
+            console.log(data);
+            if(data['image_data'] != '') {
+                disp = imageDisplay.apply(data);
+            } else {
+                disp = cellDisplay.apply(data);
+            }
             return {
-                rowBody: cellDisplay.apply(data),
+                rowBody: disp,
                 rowBodyCls: 'codeview',
                 rowBodyColspan: this.view.headerCt.getColumnCount(),
             };

File yt/gui/reason/utils.py

     contents = open(filename).read()
     payload_handler = PayloadHandler()
     payload_handler.add_payload(
-        {'type': 'cell_contents',
+        {'type': 'script',
          'value': contents}
     )
     return
     else:
         raise RuntimeError
     ph = PayloadHandler()
-    payload = {'type':'png_string',
+    payload = {'type':'cell',
+               'output': '',
+               'input': '',
+               'raw_input': '',
                'image_data':img_data}
     ph.add_payload(payload)