This is probably a trivial problem with a trivial solution, but I can't find any examples on choosing fonts in Perl/Tk. So here's a whittled-down example of my problem.
This script WORKS FINE in Win32 using ActivePerl 5.8.4.
But on Solaris and Linux, a very small number of Chinese characters do not appear properly (in items 124, 125, and 128 in the pulldown menu). Is there a simple explanation for this?
My guess is that, in Windows, the default font happens to cover the Chinese characters I'm using. But since I'm not specifying any particular font in the script, the default font for Solaris/Linux does not cover all the Chinese characters I am using (which would partially explain why it took so long to come back after selecting Chinese characters).
So the simple question is ... how do I specify fonts for Perl/Tk and will this fix the problem?
Another question, was this a decent method of coding or is there a better way? Seems I'll have flexibility issues if I want configurable menu entries (based on user-selections from the menu) because I can't put if-else control inside a menuitem definition.
Thanks,
Perl/Tk novice
(Jan 10: Code replaced with this shorter example -- shockers)
#!/bin/env perl -w
use Tk;
use Tk::Menu;
use Encode::Unicode;
use strict;
my $exit_val = 0;
my $menubar;
my $menuitems;
my $top;
my %code =
(
60 => "Contactor Repair | \x{4FEE}\x{593E}\x{8173}",
120 => "Change Cleaning Disk | \x{66F4}\x{63DB}\x{786C}\x{789F}",
180 => "Change Loadboard | \x{66F4}\x{63DB}\x{6E2C}\x{8A66}\x
+{677F}",
240 => "Change LN2 | \x{66F4}\x{63DB}\x{6DB2}\x{614B}\x
+{6C2E}",
);
#----- Main ----------------------------
$top = new MainWindow;
$top -> title ("Select");
$top -> geometry ("200x50+10+10");
$menuitems =
[
[Cascade => "SELECT", -menuitems =>
[
[ Button => "$code{ 60}", -font => "courier", -command => [\&exit_
+r, 60] ],
[ Button => "$code{120}", -font => "courier", -command => [\&exit_
+r, 120] ],
[ Button => "$code{180}", -font => "courier", -command => [\&exit_
+r, 180] ],
[ Button => "$code{240}", -font => "courier", -command => [\&exit_
+r, 240] ],
]
],
]; # end menuitems
$menubar = $top->Menu (-menuitems => $menuitems);
$top->configure(-menu => $menubar);
MainLoop;
exit ($exit_val);
sub exit_r
{
$exit_val = shift;
$top -> destroy;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.