Hi, could someone help me use the new GTK4 Expressions for binding to nested properties in python.
The GTK4 documentation on Expressions suggests that expressions can be used to bind to nested GObject properties like this->item->name
, and this is precisely what I am trying to achieve in python3 code.
In the following code example, the last line shows what I am trying to do:
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import GObject, Gtk
from gi.repository.GObject import Property
# example classes
class Address(GObject.Object):
line1 = Property(type=str)
line2 = Property(type=str)
line3 = Property(type=str)
class Person(GObject.Object):
name = Property(type=str)
address = Property(type=Address)
# example objects
john = Person()
john.name = "John Doe"
addr = Address()
addr.line1 = "15 My Ave"
addr.line2 = "1234 Country"
addr.line3 = "The State"
john.address = addr
widget = Gtk.Label
# question: how can I bind the label to john's address line1?
# similar to the following (disfunctional) pseudocode:
widget.bind_property_using_expression("label", john, "address.line1")
thank you! best regards, Johannes