glade and signals connection



 I'm new to python, gtk and glade, so I'm sorry if the question is dumb.

I'm trying to learn gtk in its Python flavor (pyGObject). I choose to start
from the graphical GUI builder glade that I run under Windows (it taked
some time to find the latest Windows build in Msys2 environment... the
binaries on the web site are quite old).

The question. In glade I can specify the name of the signals I want to
process. For example, I set in the Handler column of Signals page, the
"clicked" signal of button as on_btnFoo_clicked.

In Python code, I need to "register" the correct functions to the signals.
I'm using the following strategy:

     def __init__(self):
        handlers = {
            "onDeleteWindow": self.onDeleteWindow,
            "on_btnFoo_clicked": self.on_btnFoo_clicked,
        }

        builder = Gtk.Builder()
        builder.add_from_file("example.glade")
        builder.connect_signals(handlers)


Of course the role of handlers dictionary is of very little importance: the
name of the key is identical to the name of the function (at least, in my
code) .
Is it possible to avoid the handlers dictionary at all and use the glade to
connect the signals?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]