Perl Tk里面的控件如何显示中文

Perl Tk里面的控件如何显示中文

如题, 需要用到什么模块吗?


QUOTE:
原帖由 redwyz 于 2008-1-3 11:21 发表
如题, 需要用到什么模块吗?

上周才遇到的问题

use encoding("gb2312");
或========================
Encode::decode("gb2312", $var)
Encode::encode("gb2312", $var)
但是字体,字号怎么改就不知道了,默认的字太小很不好看

[Copy to clipboard] [ - ]
CODE:
#!perl
use Tk;
use strict;
use Encode;
#use encoding("gb2312");
#BEGIN {
#  if ($^O eq 'MSWin32') {
#    require Win32::Console;
#    Win32::Console::Free( );
#  }
#}

my $owner_dbfile;
my $log_file;
my $owner_dbfile_v;
my $log_file_v;

my $mw = MainWindow->new();
$mw->geometry("800x250+400+450");
$mw->title('OwnChk');

my $selfile1 = $mw->Button(-text => decode("gb2312", '选择owner_db文件'),
                           -command => \&open_file1)->pack;
$mw->Label(-textvariable => \$owner_dbfile_v)->pack;

my $selfile2 = $mw->Button(-text => decode("gb2312" ,'选择clearcase log文件'),
                           -command => \&open_file2)->pack;
$mw->Label(-textvariable => \$log_file_v)->pack;

my $exit = $mw->Button(-text => 'run check',
                       -command => [$mw => 'destroy']);
$exit->pack;

my $types1 = [ ['excel files', '.xls'],
              ['All Files', '*'],];
my $types2 = [ ['excel files', '.txt'],
              ['All Files', '*'],];
MainLoop;

sub open_file1 {
  $owner_dbfile_v = $mw->getOpenFile(-filetypes => $types1);
  print "You chose to open '$owner_dbfile_v'\n" if $owner_dbfile_v;
  $owner_dbfile = encode("gb2312", $owner_dbfile_v);
  print "You chose to open '$owner_dbfile'\n" if $owner_dbfile;
}

sub open_file2 {
  $log_file_v = $mw->getOpenFile(-filetypes => $types2);
  print "You chose to open '$log_file_v'\n" if $log_file_v;
  $log_file = encode("gb2312", $log_file_v);
  print "You chose to open '$log_file'\n" if $log_file;
}

多谢