this is interesting, when "running" eval
- From: Lich Lee <a_banknote yahoo com cn>
- To: gtk-perl-list gnome org
- Subject: this is interesting, when "running" eval
- Date: Tue, 24 Aug 2004 22:31:20 +0800 (CST)
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;
$window->show_all;
my $entry= Gtk2::Entry->new;
$panel->add($entry);
$entry->signal_connect(key_press_event => \&caller);
$panel->show_all;
Gtk2->main;
sub caller{
my($self, $event) = @_;
if( $event->keyval == $Gtk2::Gdk::Keysyms{'Return'}
){
$text = $self->get_text;
chomp($text);
print "$text\n";
eval $text;
$window->show_all;
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!?
150万曲MP3疯狂搜,带您闯入音乐殿堂
http://music.yisou.com/
美女明星应有尽有,搜遍美图、艳图和酷图
http://image.yisou.com
1G就是1000兆,雅虎电邮自助扩容!
http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]