|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
gobject.connectHi everyone,
I am new to this mailing list. I am working on a program to perform data analysis in python. This program is based on a library already developped, that uses pygtk to create data-handling objects.
This data object inherits from gobject.GObject, and defines a few signals "new-data-point". I would like to connect this signal to a few functions, specifying the arguments of these functions. I have read the PyGTK webpage (http://www.pygtk.org/docs/pygobject/class-gobject.html#method-gobject--connect), which specifies that i just have to concatenate in the "connect" call the arguments: "object.connect("signal_name",handler,arg1,arg2,arg3)
I therefore have written: data.connect("new-data-point", handler,'text') and defined the handler function as suggested: def handler(object,arg1,arg2,arg3)
def handler(data,argument): print data print argument However, when i do execute the "connect" function, i get the error message:
"connect takes exactly 3 arguments (4 given). Could you tell me how i could then specify arguments for the functions to be called when the signal is given ? Bests,
Pierre
_______________________________________________ pygtk mailing list pygtk@... http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/ |
|
|
Re: gobject.connectOp 23-04-12 12:44, Pierre Barthelemy schreef:
> Hi everyone, > > I am new to this mailing list. I am working on a program to perform > data analysis in python. This program is based on a library already > developped, that uses pygtk to create data-handling objects. > This data object inherits from gobject.GObject, and defines a few > signals "new-data-point". > > I would like to connect this signal to a few functions, specifying the > arguments of these functions. I have read the PyGTK webpage > (http://www.pygtk.org/docs/pygobject/class-gobject.html#method-gobject--connect), > which specifies that i just have to concatenate in the "connect" call > the arguments: "object.connect("signal_name",handler,arg1,arg2,arg3) > > I therefore have written: > > data.connect("new-data-point", handler,'text') > > > and defined the handler function as suggested: def > handler(object,arg1,arg2,arg3) > > def handler(data,argument): > print data > print argument > > However, when i do execute the "connect" function, i get the error > message: > "connect takes exactly 3 arguments (4 given). this applies to all Python functions in the future when you encounter this exception): def handler(*args): print args And see for yourself which arguments are passed. If the error is in the data.connect() call, try with only one argument and see if it passes, then two, then ... Without code, it's impossible for us to say what it expects. Cheers, Timo > > Could you tell me how i could then specify arguments for the functions > to be called when the signal is given ? > > Bests, > > Pierre > > > _______________________________________________ > pygtk mailing list pygtk@... > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://faq.pygtk.org/ _______________________________________________ pygtk mailing list pygtk@... http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/ |
| Free embeddable forum powered by Nabble | Forum Help |