Question

How can I pass user_data to callbacks defined in separated class. consider:

from gi.repository import Gtk

class CallBacks(object):
    def onQuit(self, widget, app):
        pass

class App(Gtk.Application):
    def __init__(self):
        super().__init__(application_id="org.stof.example")

        callbacks = CallBacks()

        self.builder = Gtk.Builder.new_from_file("example.ui")
        self.builder.connect_signals(callbacks)

        self.register()

how can I pass the app instance to callbacks functions ? something like self.builder.connect_signals(callbacks, self)

Was it helpful?

Solution

I don't know if this is possible, and the time is not my friend right now, so I've done a workaround, that's pass the app instance in CallBacks constructor.

callbacks = CallBacks(self)

def __init__(self, app): on CallBacks class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top