Re: Cómo coger datos de un combobox
![Nota Nota](https://perlenespanol.com/foro/styles/prosilver/imageset/icon_post_target.gif)
Hola. He puesto el código igual que tú, pero cambio las instrucciones de la subrutina por esto:
Y me da este error en la consola:
¿¿Por qué puede ser??
Using perl Syntax Highlighting
- #!/usr/bin/perl
- use strict;
- use warnings;
- use diagnostics;
- use Gtk2 '-init';
- use Glib qw/TRUE FALSE/;
- my @valores = 1 .. 30;
- ## Titular
- my $frase = Gtk2::Label->new('Indique cuántos documentos desea buscar');
- ## Lista de opciones
- my $comboBox = Gtk2::ComboBox->new_text();
- for (@valores) {
- $comboBox->append_text($_);
- }
- $comboBox->set_active (0);
- ## Tabla de la lista
- my $tabla_combo= Gtk2::Table->new(2,3,TRUE);
- $tabla_combo->attach_defaults($comboBox, 1,2,1,2);
- ## Botón Atrás
- my $boton_atras = Gtk2::Button->new_with_label('Atras');
- $boton_atras->signal_connect(clicked => \&atras);
- ## Botón Ok
- my $boton_ok = Gtk2::Button->new_from_stock('gtk-ok');
- $boton_ok->signal_connect(clicked => \&ir_a);
- ## Tabla de los botones
- my $tabla_botones = Gtk2::Table->new(3,5, TRUE);
- $tabla_botones->attach_defaults($boton_atras, 1,2,1,2);
- $tabla_botones->attach_defaults($boton_ok, 3,4,1,2);
- ## Tabla contenedor
- my $tabla_contenedor = Gtk2::Table->new(3,7, FALSE);
- $tabla_contenedor->attach_defaults($frase, 1,2,1,2);
- $tabla_contenedor->attach_defaults($tabla_combo, 1,2,3,4);
- $tabla_contenedor->attach_defaults($tabla_botones, 1,2,5,6);
- ## Ventana principal
- my $ventana = Gtk2::Window->new('toplevel');
- $ventana->set_title('Documentos');
- $ventana->set_border_width(20); # 20px
- ## Estilo
- my $rc_style = Gtk2::RcStyle->new;
- $rc_style->bg_pixmap_name('normal', 'fondo.jpg');
- $ventana->modify_style($rc_style);
- $ventana->signal_connect (delete_event => sub {Gtk2->main_quit; TRUE}); # Cierre de la app
- $ventana->add($tabla_contenedor);
- $ventana->set_default_size(200,200);
- $ventana->set_keep_above(TRUE);
- $ventana->set_resizable(FALSE);
- $ventana->move(380, 300);
- $ventana->show_all;
- Gtk2->main;
- sub ir_a {
- exec "./ejecutando_estoy_en_noja.pl $comboBox->get_active() $_[0] $_[1] $_[2] $_[3] $_[4] $_[5]"; #ESTA
- #print 'Índice: ', $comboBox->get_active(), "\n";
- #print 'Texto : ', $comboBox->get_active_text(), "\n";
- }
- sub atras{
- Gtk2->main_quit;
- #my $punto=".";
- #exec "$punto$_[0] $_[1]";
- }
- ###########################################3
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
Y me da este error en la consola:
Using text Syntax Highlighting
Use of uninitialized value in concatenation (.) or string at ./num_docs.pl line
67 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.
To help you figure out what was undefined, perl tells you what operation
you used the undefined value in. Note, however, that perl optimizes your
program and the operation displayed in the warning may not necessarily
appear literally in your program. For example, "that $foo" is
usually optimized into "that " . $foo, and the warning will refer to
the concatenation (.) operator, even though there is no . in your
program.
sh: Syntax error: "(" unexpected
67 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.
To help you figure out what was undefined, perl tells you what operation
you used the undefined value in. Note, however, that perl optimizes your
program and the operation displayed in the warning may not necessarily
appear literally in your program. For example, "that $foo" is
usually optimized into "that " . $foo, and the warning will refer to
the concatenation (.) operator, even though there is no . in your
program.
sh: Syntax error: "(" unexpected
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4
¿¿Por qué puede ser??