Trying to use <Image> causes IconFactory._get_pixbuf_url() error

On Tryton 7.6.6, I am trying to display an image like this:

<image type="url" name="/some/path/filename.jpg" size="200"/>

But I get:

File "dev/venv/lib/python3.13/site-packages/tryton/gui/window/view_form/view/list.py", line 1128, in __sig_switch
    if not self.screen.row_activate() and self.children_field:
           ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "dev/venv/lib/python3.13/site-packages/tryton/gui/window/view_form/screen/screen.py", line 547, in default_row_activate
    self.switch_view(view_type='form')
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "dev/venv/lib/python3.13/site-packages/tryton/gui/window/view_form/screen/screen.py", line 615, in switch_view
    self.display()
    ~~~~~~~~~~~~^^
  File "dev/venv/lib/python3.13/site-packages/tryton/gui/window/view_form/screen/screen.py", line 1007, in display
    view.display()
    ~~~~~~~~~~~~^^
  File "dev/venv/lib/python3.13/site-packages/tryton/gui/window/view_form/view/form.py", line 563, in display
    widget.state_set(record)
    ~~~~~~~~~~~~~~~~^^^^^^^^
  File "dev/venv/lib/python3.13/site-packages/tryton/gui/window/view_form/view/form_gtk/state_widget.py", line 73, in state_set
    pixbuf = common.IconFactory.get_pixbuf_url(
        name, size=size, size_param=self.attrs.get('url_size'))
  File "dev/venv/lib/python3.13/site-packages/tryton/common/common.py", line 230, in get_pixbuf_url
    return cls._get_pixbuf_url(url, size, size_param)
           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^

TypeError: IconFactory._get_pixbuf_url() takes from 2 to 3 positional arguments but 4 were given

(Note that I abbreviated the file paths for readability.)

I tried adding the size and url_size parameters, but that did not help. What am I missing here?

The name attribute must be the name of a fields.Binary that stores the image data or the name of any images already present in the tryton/data/pixmaps/tryton/ folder (if the type is url it is a path relative to the server URL).

That I understood. But I thought by setting the type to url I could display arbitrary image files. Is that not the case?

Only images served by the trytond server (at least from the same URL).

1 Like

Thanks. I now implemented a field that serves the image in question, this works splendidly.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.