perl-gtk newbie question
- From: Luis Villa <liv duke edu>
- To: gtk-perl-list gnome org
- Subject: perl-gtk newbie question
- Date: Tue, 21 Nov 2000 18:54:44 -0500 (EST)
So, I've searched these lists for a while and been unable to find a good
answer to this question: given an OptionMenu, how can I figure out what
the selected option is? I'm a gtk newbie, and while I'm reasonably good
with perl, none of it has been in an OO environment, so there are some
issues with classes and the like that I think I'm missing. Here is what
I'm trying to do (code more or less verbatim):
$motor_dir_option_menu = $g->get_widget('motor_dir');
$dir_menu = $motor_dir_option_menu->get_menu();
$dir = ($dir_menu->get_active->children)[0]->get;
print STDERR 'DIR:'.$dir;
This dies, telling me (when get_active is called on $dir_menu) that
$dir_menu is not actually a menu, but a widget, and so it can't locate the
method get_active via package "Gtk::Widget". Upon looking through the gtk
perl docs, I realize that this is the "correct" behavior: get_menu should
return a widget. So, I guess my question breaks down into two parts:
1) Can I turn the widget returned by get_menu into an actual menu object
so that I can call the get_active method?
and
2) this seems ugly and un-intuitive. Is there a better way to figure
out which menu item has been selected? I gather from the lists (this one,
gtk, and gtk-devel) that there is not (see:
http://mail.gnome.org/archives/gtk-perl-list/2000-September/msg00035.html
among others) but one can dream ;)
Anyway, thanks for helping out a newbie...
Luis
P.S. In case it matters, the code above is contained in a callback for
another button. $g is a Gtk::GladeXML object.
-----------------------------------------------------------------------
"Nobody ever said that democracy was simple or efficient."
Florida Election Board Member Bob Crawford.
-----------------------------------------------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]