William Stein wrote: > On Mon, Apr 20, 2009 at 10:17 AM, Jason Grout > <jason-s...@creativetrax.com> wrote: >> William Stein wrote: >>> On Mon, Apr 20, 2009 at 9:50 AM, Nick Alexander <ncalexan...@gmail.com> >>> wrote: >>>>> If there's not currently an easy way to do this, >>> There isn't one. >>> >>>>> I think this could >>>>> easily be accomplished by having the show command return the "<img >>>>> src='cell://filename'/>" tag that we would normally do by hand, >>>>> instead >>>>> of just generating an image, returning None, and letting the notebook >>>>> automatically pick up the image at the end of the output. >>> Yes, that does seem like a good idea. Try it. >> >> Yep, I've been trying the last few minutes. Part of what messes things >> up is that the output of a cell does not include anything but the last >> command, so a cell like: >> >> show(graphic) >> print "hi" >> >> will not print out the <img> tag returned by show. >> >> There was discussion about this a while ago, IIRC. Does anyone know if >> anything was done about it? (it's obviously not fixed...) >> >> You can see the problem in a cell that looks like this: >> >> s="hi" >> s >> s >> >> It will only print out "hi" once (i.e., only display the result of the >> last command) >> >> Jason > > > I think you're confused. Try the following little demo worksheet, and > all will be clear: > > > {{{id=15| > def myshow(G, *args, **kwds): > filename = 'sage-%s.png'%randint(0,1000000) > G.save(filename, *args, **kwds) > html("<img src='cell://%s'>"%filename) > /// > }}} > > {{{id=14| > print "First plot sin:" > myshow(plot(sin,0,2),figsize=[2,1]) > print "And now for cos" > myshow(plot(cos,0,2),figsize=[2,1]) > print "Cool, eh?" > /// > > First plot sin: > <html><font color='black'><img src='cell://sage-213578.png'></font></html> > And now for cos > <html><font color='black'><img src='cell://sage-462904.png'></font></html> > Cool, eh? > }}}
So apparently html() contains the print function? This worksheet illustrates the problem with the approach: {{{id=15| def myshow(G, *args, **kwds): filename = 'sage-%s.png'%randint(0,1000000) G.save(filename, *args, **kwds) html("<img src='cell://%s'>"%filename) /// }}} {{{id=14| print "First plot sin:" plot1=myshow(plot(sin,0,2),figsize=[2,1]) # Shows the plot anyway! print "And now for cos" plot2=myshow(plot(cos,0,2),figsize=[2,1]) # Shows the plot anyway! print "Cool, eh?" /// First plot sin: <html><font color='black'><img src='cell://sage-558439.png'></font></html> And now for cos <html><font color='black'><img src='cell://sage-118258.png'></font></html> Cool, eh? }}} {{{id=16| plot1 # Should show the plot /// }}} {{{id=17| plot2 # Should show the plot /// }}} {{{id=18| /// }}} -- Jason Grout --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---