2008年6月15日星期日

Perl :GTK2 设置文本样式,比如彩色、斜体之类的

来源:Listing 3
 


代码如下:
#!/usr/bin/perl  

use Gtk2 -init;
use strict;

my $window = Gtk2::Window->new;
$window->signal_connect('delete_event', sub { Gtk2->main_quit });
$window->set_border_width(8);
$window->set_title('Label Example');

my $label = Gtk2::Label->new;

my $markup = <<"END";  
This is some plain text.  
<b>This is some bold text.</b> 
<span size="small">This is some small text.</span>  
<span size="large">This is some large text.</span>  
<span foreground="blue">This is blue.</span> 
<span style="italic">This is italic.</span> 
<tt>This is monospace.</tt>  
END  

$label->set_markup($markup);  

$window->add($label);  
$window->show_all; 

Gtk2->main;  

exit;


没有评论:

发表评论