Gtk2 - perl 学习记录
2005-04-06 16:55
483 查看
HBox和VBox创建时有两个参数:
new(是否平分每个box, 内部各个Widget之间的距离)
Window设置内部间隔:
set_border_width($px)
让scroll到最底部:
my $buffer = $textview->get_buffer;
# create a mark at the end of the buffer, with right gravity,
# so that when you insert text, the mark always stays on
# the right (at the end).
my $end_mark = $buffer->create_mark ('end', $buffer->get_end_iter, FALSE);
# every time we insert text, scroll to that mark.
$buffer->signal_connect (insert_text => sub {
$textview->scroll_to_mark ($end_mark, 0.0, TRUE, 0.0, 1.0);
});
# display the output of some long-running command...
open IN, "sleep 1; ls -l |";
Glib::IO->add_watch (fileno IN, ['in', 'hup'], sub {
my ($fd, $condition) = @_;
if ($condition >= 'in') {
$buffer->insert ($buffer->get_end_iter, scalar );
}
if ($condition >= 'hup') {
close IN;
return FALSE;
}
return TRUE;
});
Gtk2->main;
LINK:http://gtk2-perl.sourceforge.net/faq/#46
new(是否平分每个box, 内部各个Widget之间的距离)
Window设置内部间隔:
set_border_width($px)
让scroll到最底部:
use Glib qw(FALSE); use Gtk2 -init; # create a window with a scrolled text view. my $window = Gtk2::Window->new; $window->signal_connect (delete_event => sub {exit}); my $scroll = Gtk2::ScrolledWindow->new; my $textview = Gtk2::TextView->new; $scroll->add ($textview); $window->add ($scroll); $window->show_all;
my $buffer = $textview->get_buffer;
# create a mark at the end of the buffer, with right gravity,
# so that when you insert text, the mark always stays on
# the right (at the end).
my $end_mark = $buffer->create_mark ('end', $buffer->get_end_iter, FALSE);
# every time we insert text, scroll to that mark.
$buffer->signal_connect (insert_text => sub {
$textview->scroll_to_mark ($end_mark, 0.0, TRUE, 0.0, 1.0);
});
# display the output of some long-running command...
open IN, "sleep 1; ls -l |";
Glib::IO->add_watch (fileno IN, ['in', 'hup'], sub {
my ($fd, $condition) = @_;
if ($condition >= 'in') {
$buffer->insert ($buffer->get_end_iter, scalar );
}
if ($condition >= 'hup') {
close IN;
return FALSE;
}
return TRUE;
});
Gtk2->main;
LINK:http://gtk2-perl.sourceforge.net/faq/#46
相关文章推荐
- perl学习(9) 实例:取出操作时间最长的100个记录
- Perl学习记录(一) -- HelloWorld
- perl语言学习记录
- perl学习记录(二)
- Perl学习记录(二) -- 逻辑控制
- perl学习记录(一)
- Makefile Perl学习记录
- Perl 学习记录3 基本构件的堆栈:列表与数组
- 学习GTK时候临时记录的一些东西备忘
- perl学习(9) 实例:取出操作时间最长的100个记录
- Perl 学习记录2 控制程序流
- Selenium 网页测试工具和perl脚本结合,我自己记录的学习过程
- Perl 学习记录1 Perl的基本构件:数字和字符串
- perl快速学习记录
- perl学习记录
- perl学习记录(三)
- perl语言学习记录
- 因学习需要记录自己的计划,故遍历了自己的目录
- 【Novice】 03- diabetes 案例 学习记录
- N2CMS Mvc Examples 学习记录 (2) – 模型类