glib.ProxyInterface

class dbus_next.glib.ProxyInterface(bus_name, path, introspection, bus)

Bases: dbus_next.proxy_object.BaseProxyInterface

A class representing a proxy to an interface exported on the bus by another client for the GLib MessageBus implementation.

This class is not meant to be constructed directly by the user. Use ProxyObject.get_interface() on a GLib proxy object to get a proxy interface.

This class exposes methods to call DBus methods, listen to signals, and get and set properties on the interface that are created dynamically based on the introspection data passed to the proxy object that made this proxy interface.

A method call takes this form:

def callback(error: Exception, result: list(Any)):
    pass

interface.call_[METHOD](*args, callback)
result = interface.call_[METHOD]_sync(*args)

Where METHOD is the name of the method converted to snake case.

To call a method, provide *args that correspond to the in args of the introspection method definition.

To asynchronously call a method, provide a callback that takes an error as the first argument and a list as the second argument. If the call completed successfully, error will be None. If the service returns an error, it will be a DBusError with information about the error returned from the bus. The result will be a list of values that correspond to the out args of the introspection method definition.

To synchronously call a method, use the call_[METHOD]_sync() form. The result corresponds to the out arg of the introspection method definition. If the method has more than one otu arg, they are returned within a list.

To listen to a signal use this form:

interface.on_[SIGNAL](callback)

To stop listening to a signal use this form:

interface.off_[SIGNAL](callback)

Where SIGNAL is the name of the signal converted to snake case.

DBus signals are exposed with an event-callback interface. The provided callback will be called when the signal is emitted with arguments that correspond to the out args of the interface signal definition.

To get or set a property use this form:

def get_callback(error: Exception, value: Any):
    pass

def set_callback(error: Exception)
    pass

interface.get_[PROPERTY](get_callback)
value: Any = interface.get_[PROPERTY]_sync()

interface.set_[PROPERTY](set_callback)
interface.set_[PROPERTY]_sync(value)

Where PROPERTY is the name of the property converted to snake case.

The value must correspond to the type of the property in the interface definition.

To asynchronously get or set a property, provide a callback that takes an Exception as the first argument. If the call completed successfully, error will be None. If the service returns an error, it will be a DBusError with information about the error returned from the bus.

If the service returns an error for a synchronous DBus call, a DBusError will be raised with information about the error.