How to display a list of files from blueprint?

gtk has a class DirectoryList which is a ListModel of FileInfo

since FileInfo doesn;t have properties i tried to use a function to get the filename:

ListView list_view {
  factory: BuilderListItemFactory {
    template ListItem {
      child: Label {
        label: bind $g_file_info_get_name((template.item as <Gtk.ListItem>).item as <Gio.FileInfo>) as <string>;
      };
    }
  };
}

but when i create a Gtk.MultiSelection with a Gtk.DirectoryList in python and set it as the list_view’s model , many of these errors (probably one for each file) are printed in the terminal:

AttributeError: 'ListItem' object has no attribute '__gtktemplate_methods__'
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/gi/_gtktemplate.py", line 63, in do_create_closure
    if func_name not in current_object.__gtktemplate_methods__:
AttributeError: 'ListItem' object has no attribute '__gtktemplate_methods__'
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/gi/_gtktemplate.py", line 63, in do_create_closure
    if func_name not in current_object.__gtktemplate_methods__:

what is python doing here?

it turned out to be that it’s because the listview was a child of a python subclass (gtk#4828).
after moving into a separate file and loading it with new_from_resource, i have no errors, but the labels are still blank :frowning:

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