Debian Codegraph @

docs/tutorials/gtk4/display-widgets/picture.rst

raw
1 .. currentmodule:: gi.repository
2
3 Picture
4 =======
5
6 :class:`Gtk.Picture` displays an image at its natural size.
7 Many convenience functions are provided to make pictures simple to use.
8 For example, if you want to load an image from a file you can use
9 :meth:`Gtk.Picture.new_for_filename`.
10
11 You can influence how the image is displayed inside the :class:`Gtk.Picture` by
12 changing :attr:`Gtk.Picture.props.content_fit`. See :class:`Gtk.ContentFit` for
13 details.
14 Also :attr:`Gtk.Widget.props.halign` and :attr:`Gtk.Widget.props.valign` can be
15 used to set whether the picture will fill all available space or is displayed at its
16 original size.
17
18 Sometimes an application will want to avoid depending on external data files,
19 such as image files.
20 See the documentation of :class:`Gio.Resource` inside GIO, for details.
21 In this case, :meth:`Gtk.Picture.new_for_resource` and
22 :meth:`Gtk.Picture.set_resource`, should be used.
23
24 .. note:: This example requires a GTK version higher o equal to ``4.8``.
25
26 Example
27 -------
28
29 .. image:: images/picture.png
30
31 .. literalinclude:: examples/picture.py
32 :linenos: