[Glade-users] glade-3 and user data



On Fri, Jun 5, 2009 at 6:46 PM, Gerald Britton<gerald.britton at gmail.com> wrote:
I think that the user data should actually be another widget in this case.

Yes, user data can only be another widget or object in the project;
and it will be
the first argument to the callback not the last.

Cheers,
           -Tristan




On 6/5/09, Keith Eberle <keith.eberle at gmail.com> wrote:
Hmm...
When I run this ($ pyton ./myglade) it prints:
./myglade:15: GtkWarning: Could not lookup object somedata on signal clicked
of object button
? builder.connect_signals(self)

"somedata" is the data I entered in the User Data field in Glade.

Anyway, I printed the values of all parameters the signal handler received:

? ? def on_button_clicked(self, widget, data=None):
? ? ? ? print self
? ? ? ? print widget
? ? ? ? print data

And I see:
<__main__.MyClass object at 0xb7d9aaec>
<gtk.Button object at 0x9abf6bc (GtkButton at 0x9b6d820)>
None

I was expecting to see that "print self" printed "somedata"...

(First time using these mailing lists too... very confusing, so I hope this
reply works)

keith


On Tue, Jun 2, 2009 at 10:20 AM, Alexey Kurochkin
<alexey.kurochkin at pathfinderlwd.com> wrote:
On Mon, 2009-06-01 at 22:06 -0400, Keith Eberle wrote:
Hi all,

I'm using a combination of Glade3/PyGTK to start my GTK+ learnings.
I'm starting off fresh with the GtkBuilder way too. ?Doing well so
far, but I'm having trouble using the "User Data" field in Glade. ?I
found another message about this,
http://lists.ximian.com/pipermail/glade-users/2009-April/004314.html,
but I don't really understand what to do.

Using this as an example, what do I have to do differently?

class MyClass(object):
? def __init__(self):
? ? builder = gtk.Builder()
? ? builder.add_from_file('myglade.xml')
? ? builder.connect_signals(self)

I assume that was the "autoconnect" method described in that other
post. ?I tried something like this, but still doesn't work:

class MyClass(object):
? def __init__(self):
? ? builder = gtk.Builder()
? ? builder.add_from_file('myglade.xml')
? ? builder.connect_signals({
? ? ? ? 'on_button_clicked': self.on_button_clicked,
? ? })

? def on_button_clicked(self, widget, user_data=None):
? ? print user_data

Here, if you put something into "User data" field in your glade file, it
will appear as self, and the button object itself will appear as
user_data. That what it means "swapped". At least that how it was in
glade 3.4.x, I did not check if builder still does that, though.

GtkBuilder did not change in that respect, what we need is to
add api to builder signal parsing so that the swapped flag to
signal connect can be optional (this will be less confusing of course).

Cheers,
? ? ? ? ? -Tristan


--
Sent from my mobile device

Gerald Britton
_______________________________________________
Glade-users maillist ?- ?Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users





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