Hi I have this code ## Master hash to define widgets with options ## my %widgets=( 1=>{name=>'$open_hbox',type=>'Gtk2::HBox',action=>'new',opts=>[0,0],wname=>'open_hbox'}, 2=>{name=>'$encode_open_lab',type=>'Gtk2::Label',action=>'new',opts=>[$sel_opts_open_lab],wname=>'open_label'}, 3=>{name=>'$image',type=>'Gtk2::Image',action=>'new_from_stock',opts=>['gtk-open','small-toolbar'],wname=>'file_hbox'}, 4=>{name=>'$delay',type=>'Gtk2::Entry',action=>'new',opts=>[],wname=>'delay'}, 5=>{name=>'$delay_label',type=>'Gtk2::Label',action=>'new',opts=>["Delay action in Minutes"],wname=>'delay_label'}, 6=>{name=>'$delay_hbox',type=>'Gtk2::HBox',action=>'new',opts=>[0,0],wname=>'delbox'}, 7=>{name=>'$btn_open',type=>'Gtk2::Button',action=>'new',opts=>[],wname=>'btn_open'}, 8=>{name=>'$sel_opts_frame',type=>'Gtk2::Frame',action=>'new',opts=>[],wname=>'sel_opts_frame'}, 9=>{name=>'$sel_opts_mod_lab',type=>'Gtk2::Label',action=>'new',opts=>[$sel_opts_title_lab],wname=>'mod_opts_label'}, 10=>{name=>'$title_frame',type=>'Gtk2::Frame',action=>'new',opts=>[],wname=>'title_frame'}, 11=>{name=>'$sel_opts_hbox',type=>'Gtk2::HBox',action=>'new',opts=>[0,0],wname=>'sel_opts_hbox'}, 12=>{name=>'$sel_opts_vbox',type=>'Gtk2::VBox',action=>'new',opts=>[0,1],wname=>'sel_opts_vbox'}, 13=>{name=>'$enc_hbox',type=>'Gtk2::HBox',action=>'new',opts=>[0,0],wname=>'enc_hbox'}, ); ## calls function to create widgets and returns a reference to an array with widgets ## my $widgets=&create_widgets(\%widgets); ## creates variables pointing to widgets in current scope ## my ($open_hbox,$encode_open_lab,$image,$delay,$delay_label,$delay_hbox,$btn_open,$sel_opts_frame,$sel_opts_mod_lab,$title_frame,$sel_opts_hbox,$sel_opts_vbox,$enc_hbox)=(@{$widgets});
which calls sub create_widgets { my $widgets=shift; my %widgets=%{$widgets}; my @widgets; foreach my $keys (sort {$a<=>$b} keys %widgets){ no strict 'refs'; my $action=$widgets{$keys}->{action}; my $w=eval($widgets{$keys}->{name}); $w=$widgets{$keys}->{type}->$action(@{$widgets{$keys}->{opts}}); $w->set_name($widgets{$keys}->{wname}); push @widgets,$w; } return \...@widgets; } Obviously there is a major issue with the need to have the list in the right order. So I am wondering if anyone knows of a better and cleaner way to do this thanks _______________________________________________ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list