##// END OF EJS Templates
Embed image as default...
Matthias BUSSONNIER -
Show More
@@ -422,7 +422,7 b' class Image(DisplayObject):'
422
422
423 _read_flags = 'rb'
423 _read_flags = 'rb'
424
424
425 def __init__(self, data=None, url=None, filename=None, format=u'png', embed=False):
425 def __init__(self, data=None, url=None, filename=None, format=u'png', embed=None):
426 """Create a display an PNG/JPEG image given raw data.
426 """Create a display an PNG/JPEG image given raw data.
427
427
428 When this object is returned by an expression or passed to the
428 When this object is returned by an expression or passed to the
@@ -441,10 +441,24 b' class Image(DisplayObject):'
441 The format of the image data (png/jpeg/jpg). If a filename or URL is given
441 The format of the image data (png/jpeg/jpg). If a filename or URL is given
442 for format will be inferred from the filename extension.
442 for format will be inferred from the filename extension.
443 embed : bool
443 embed : bool
444 Should the image data be embedded in the notebook using a data URI (True)
444 Should the image data be embedded using a data URI (True) or be
445 or be loaded using an <img> tag. Set this to True if you want the image
445 loaded using an <img> tag. Set this to True if you want the image
446 to be viewable later with no internet connection. If a filename is given
446 to be viewable later with no internet connection in the notebook.
447 embed is always set to True.
447
448 Default is `True`, unless the keyword argument `url` is set, then
449 default value is `False`.
450
451 Note that QtConsole is not able to display images if `embed` is set to `False`
452
453 Examples
454 --------
455 # embed implicitely True, works in qtconsole and notebook
456 Image('http://www.google.fr/images/srpr/logo3w.png')
457
458 # embed implicitely False, does not works in qtconsole but works in notebook if
459 # internet connexion availlable
460 Image(url='http://www.google.fr/images/srpr/logo3w.png')
461
448 """
462 """
449 if filename is not None:
463 if filename is not None:
450 ext = self._find_ext(filename)
464 ext = self._find_ext(filename)
@@ -460,7 +474,7 b' class Image(DisplayObject):'
460 if ext == u'png':
474 if ext == u'png':
461 format = u'png'
475 format = u'png'
462 self.format = unicode(format).lower()
476 self.format = unicode(format).lower()
463 self.embed = True if filename is not None else embed
477 self.embed = embed if embed is not None else (url is None)
464 super(Image, self).__init__(data=data, url=url, filename=filename)
478 super(Image, self).__init__(data=data, url=url, filename=filename)
465
479
466 def reload(self):
480 def reload(self):
General Comments 0
You need to be logged in to leave comments. Login now