Show More
@@ -25,7 +25,7 b' Rich display' | |||||
25 | ============ |
|
25 | ============ | |
26 |
|
26 | |||
27 | The notebook and the Qt console can display richer representations of objects. |
|
27 | The notebook and the Qt console can display richer representations of objects. | |
28 |
To use this, you can define any |
|
28 | To use this, you can define any number of ``_repr_*_()`` methods. Note that | |
29 | these are surrounded by single, not double underscores. |
|
29 | these are surrounded by single, not double underscores. | |
30 |
|
30 | |||
31 | Both the notebook and the Qt console can display ``svg``, ``png`` and ``jpeg`` |
|
31 | Both the notebook and the Qt console can display ``svg``, ``png`` and ``jpeg`` | |
@@ -42,6 +42,13 b' For example::' | |||||
42 | def _repr_html_(self): |
|
42 | def _repr_html_(self): | |
43 | return "<h1>" + self.text + "</h1>" |
|
43 | return "<h1>" + self.text + "</h1>" | |
44 |
|
44 | |||
|
45 | We often want to provide frontends with guidance on how to display the data. To | |||
|
46 | support this, ``_repr_*_()`` methods can also return a data, metadata tuple where | |||
|
47 | metadata is a dictionary containing arbitrary key, value pairs for the frontend | |||
|
48 | to interpret. An example use case is ``_repr_jpeg()``, which can be set to | |||
|
49 | return a jpeg image and a ``{'height': 400, 'width': 600}`` dictionary to inform | |||
|
50 | the frontend how to size the image. | |||
|
51 | ||||
45 | There are also two more powerful display methods: |
|
52 | There are also two more powerful display methods: | |
46 |
|
53 | |||
47 | .. class:: MyObject |
|
54 | .. class:: MyObject |
General Comments 0
You need to be logged in to leave comments.
Login now