Re: glade and signals connection
- From: rastersoft <raster rastersoft com>
- To: gtk-app-devel-list gnome org
- Subject: Re: glade and signals connection
- Date: Wed, 19 Oct 2016 12:53:42 +0200
Hi:
You can create a class (and instantiate an object) with the methods, and
pass "self" to connect_signals. Something like:
class myclass:
    def __init__(self):
        builder = Gtk.Builder()
        builder.add_from_file("example.glade")
        builder.connect_signals(self)
    def onDeleteWindow(self, widget):
        blah, blah
    def on_btnFoo_clicked(self,btn):
        blah, blah
El 19/10/16 a las 09:08, Pozz Pozz escribió:
 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?
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
-- 
Nos leemos
                         RASTER    (Linux user #228804)
raster rastersoft com              http://www.rastersoft.com
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]