I have an app I'm making with pygtk and Glade.
I have a radio button series I'm trying to get working. I'm getting stumped at trying to pass user data after a button is toggled. The callback works fine, but is not being sent the user data entered next to the handler in the user data field in glade.
Just as a simple test, I did this as a part of a class:
def on_output_toggled(self, widget, data=None):
print data
within glade, there is a radiobutton that is set to signal "toggle" with on_output_toggled in the Handler and m4b as the user data.
Expected terminal output from this after the radiobutton is selected is:
m4b
What I get is:
None
What am开发者_如何转开发 I doing wrong. Nothing is being passed on the the callback other than the widget itself.
Thanks, Narnie
The "user data" you enter in Glade should actually only be the name of other widgets (or actions, or objects) defined in that Glade file. In your case, there would need to be an object named "m4b" somewhere in your Glade file.
I meet this sort of problem too, my solution is connect signals manually. I use perl-gtk3 ,Python works theoretically.
...
my $button = $builder->get_object("button");
$button->signal_connect(clicked=>\&on_output_toggled,"m4b");
...
精彩评论