Property Expression issues


I am having an issue with the Gtk.PropertyExpression class. I tried different options but I always get an error similar to:

TypeError: No means to translate argument or return value for 'GtkPropertyExpression'

Below is my code snippet:

class AppColumnView(Gtk.ColumnView):
    __gtype_name__ = "app_column_view"

    def __init__(self,):

        self.folder_path = None
        self.search_entry_value = None


        self.single_selection = Gtk.SingleSelection()
        self.sort_list_model = Gtk.SortListModel()
        self.list_store = Gio.ListStore()


        columns = [
            {"title": "Path", "property": "path", "expand": True, "setup": self.factory_setup_label, "bind": self.factory_bind_label},
            {"title": "Points (nb)", "property": "points", "expand":  False, "setup": self.factory_setup_label, "bind": self.factory_bind_label},
            {"title": "Length (km)", "property": "length", "expand":  False, "setup": self.factory_setup_label, "bind": self.factory_bind_label},
            {"title": "UpHill (m)", "property": "up_hill", "expand":  False, "setup": self.factory_setup_label, "bind": self.factory_bind_label},
            {"title": "DownHill (m)", "property": "down_hill", "expand":  False, "setup": self.factory_setup_label, "bind": self.factory_bind_label},
            {"title": "Actions", "property": None, "expand":  False, "setup": self.factory_setup_actions, "bind": None}
        for column in columns:
            column_view_column = Gtk.ColumnViewColumn()

            signal_list_item_factory = Gtk.SignalListItemFactory()
            signal_list_item_factory.connect("setup", column["setup"])

            if column["bind"]:
                signal_list_item_factory.connect("bind", column["bind"], column["property"])

                property_expression =, None, column["property"])
                string_sorter = Gtk.StringSorter()


KInd regards,

I’m sorry, but GtkExpression is not supported by the Python bindings. PyGObject has never supported instance types that are not GObject, and nobody has implemented support before GTK4 was released.

You can define expressions in the UI definition files, but you cannot access them in Python code, or create them programmatically.

Sorry to interfere with this topic, but I am experiencing a similar issue with GtkExpression in Python and I do not think opening a different topic would make sense.

Regarding what @ebassi just said, does that mean that it is not possible for Python users to utilise the search option embedded in GtkDropDown? If so, is there any way to reproduce the GTK3 behaviour of coupling GtkComboBox with GtkEntryCompletion using GTK4 Python bindings? Thank you very much for any input.

As I said, it should be possible for you to define the DropDown in a UI definition file, and create the expression there as a binding, e.g. (untested code):

<object class="GtkDropDown" id="drop-down">
  <property name="model">
    <object class="GtkStringList">
        <item>Choice 1</item>
        <item>Choice 2</item>
        <item>Choice 3</item>
        <item>Choice 4</item>
        <item>Choice 5</item>
  <property name="enable-search">true</property>
  <binding name="expression">
    <lookup name="string">GtkStringObject</lookup>

But, otherwise, no.

The GtkComboBox and GtkEntryCompletion API still exist and work in GTK4, so you can use them both in the same way as in GTK3.

1 Like


Thanks for your answer. I will give it a try with a .ui file definition.
I was not using them until now as there is no proper software like Glade managing Gtk4.
I played a bit with Cambalache but it seems to early to use it.


Hi @ebassi,

I found this topic How to pass the parameter to GtkSorter's expression with GtkColumnViewColumn? which is useful and I try to adapt the example to my use case.

So, I switched to a GtkBuilderListItemFactory instead of a SignalListItemFactory. I am using a Gio.Listore with an object called Item which is inherited from GObject.

class Item(GObject.GObject):
    __gtype_name__ = "item"

    path = GObject.Property(type=str)
    points = GObject.Property(type=int)
    length = GObject.Property(type=float)
    up_hill = GObject.Property(type=float)
    down_hill = GObject.Property(type=float)

    def __init__(self, path, points, length, up_hill, down_hill):

        self.path = path
        self.points = points
        self.length = length
        self.up_hill = up_hill
        self.down_hill = down_hill

In the ui file definition, if I set something like:

<lookup name="path" type="Item">
   <lookup name="item">GtkListItem</lookup>

The the Item type is not recognized and an error is thrown and it’s saying Invalid Type.



I found the solution by myself:

<property name="sorter">
    <object class="GtkStringSorter">
        <property name="expression">
            <lookup name="path" type="Item"/>


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