Freezing a custom property

The documentation for GObject.Object.freeze_notify says:

This method freezes all the “notify::” signals (which are emitted when any property is changed) until the thaw_notify() method is called.

When I run this program:

import gi
gi.require_version('GObject', '2.0')
from gi.repository import GObject

class Freezer(GObject.Object):
    prop = GObject.Property(type=str)

def on_changed(obj, paramspec):
    print('In on_changed, new value =', obj.get_property(

freezer = Freezer()
print('properties =', [ for p in freezer.list_properties()])

freezer.connect('notify::prop', on_changed)

with freezer.freeze_notify():
    freezer.set_property('prop', 'new value')

print('after setting, prop =', freezer.get_property('prop'))

the handler gets called despite the freeze_notify. Am I doing something wrong, or did the documentation fail to mention that freeze_notify does not work with custom properties?

The handler will be called when the with block terminates, as it will call thaw_notify().

A freeze_notify()/thaw_notify() pair is meant to be used to set multiple properties at the same time, and delay the notification step; additionally, it is used to coalesce multiple notifications on the same property.


Ah. Now I get it. That is why it is called “freezing” and not “stopping”. Thanks again.

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