this is interesting, when "running" eval

hi, I've got an instresting problem;

#!/usr/bin/perl -w
use Gtk2 '-init';
use Gtk2::Gdk::Keysyms;

my $window = Gtk2::Window -> new('toplevel');
my $panel = Gtk2::Window -> new('toplevel');
$window->signal_connect( destroy => sub {exit 0;} );
$code1 = "\$window->set_size_request(1024,768);";
$code2 = "\$window->set_size_request(500,500);";
eval $code1;
eval $code2;

my $entry= Gtk2::Entry->new;
$entry->signal_connect(key_press_event => \&caller);

sub caller{
        my($self, $event) = @_;
        if( $event->keyval == $Gtk2::Gdk::Keysyms{'Return'}
                $text = $self->get_text;
                print "$text\n";
                eval $text;
                return 1;
        return 0;

upon is my whole code;
problem is in sub caller
when I eval $text;
$text is " $window->set_size_request(x, y);"
if x and y are bigger than the original size of
$window, It can execute normally, but if they are
smaller, It seem never be executed, 
for example;
when $text is "$window->set_size_request(1024, 768);"
now the window cover whole my desktop;
but when I eval $text is
"$window->set_size_request(500, 500);"
window never gets smaller, it's still 1024*768;

but if I use: 
eval \$window->set_size_request(1024, 768);
eval \$window->set_size_request(500, 500);
instead of:
eval $text;
everything is ok, window is 500*500;
can anyone tell me what happen?
thx, alot;

Do You Yahoo!?

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