1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# -*- coding: utf-8 -*-
#
# unicodeout.rb --
#
# This demonstration script shows how you can produce output (in label
# widgets) using many different alphabets.
#
# based on Tcl/Tk8.4.4 widget demos
if defined?($unicodeout_demo) && $unicodeout_demo
$unicodeout_demo.destroy
$unicodeout_demo = nil
end
$unicodeout_demo = TkToplevel.new {|w|
title("Unicode Label Demonstration")
iconname("unicodeout")
positionWindow(w)
}
base_frame = TkFrame.new($unicodeout_demo).pack(:fill=>:both, :expand=>true)
TkLabel.new(base_frame,
:font=>$font, :wraplength=>'5.4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
ããã¯ï¼Tkã«ãããé欧米æåéåãç¨ããè¨èªã«å¯¾ãããµãã¼ãã«ã¤ãã¦ã®\
ãµã³ãã«ã§ãï¼ãã ãï¼ä¸ã®è¡¨ç¤ºã«ããã¦ããªããå®éã«ã©ã®ãããªè¡¨ç¤ºã\
ç®ã«ãããã¯ï¼ããªãã®ç°å¢ã«ã©ã®ãããªæåéåãã¤ã³ã¹ãã¼ã«ããã¦ãããã«\
大ããä¾åãã¾ãï¼ã¾ãï¼å¯¾è±¡ã¨ãªãæåéåãã¤ã³ã¹ãã¼ã«ããã¦ããªãå ´åã«\
ã©ã®ãããªè¡¨ç¤ºããªãããããããªãã®ç°å¢æ¬¡ç¬¬ã§ãï¼\
ãã³ã¼ãåç
§ããã¿ã³ãæ¼ãã¦ã½ã¼ã¹ã表示ãï¼\
Unicodeout_SampleFrameã¯ã©ã¹ã®@@fontã®å®ç¾©ãæ¸ãæãã¦\
(ãã¡ã¤ã«ã®å
容ã¯å¤æ´ããã¾ãã)\
ãåå®è¡ããã¿ã³ã®ã¯ãªãã¯ã試ãã¦ã¿ã¦ãã ããï¼
ã¹ã¯ãªãããå¯æ¬æ§ãæã¤ããã«ï¼æååã¯\\uXXXXã¨ãã\
Tclã®ã¨ã¹ã±ã¼ã表ç¾ãç¨ããUNICODEæååã§æ¸ããã¦ãã¾ãï¼\
æååã¯ï¼Tk::UTF8_Stringã¡ã½ããã«ãã£ã¦ï¼\
ãUTF8å½¢å¼ã®æååã§ãããã¨ãã\
ã¨ã³ã³ã¼ãæ
å ±ä»ãã®æååãªãã¸ã§ã¯ã\
(Tclã®ã¨ã¹ã±ã¼ã表ç¾ã®å¤ææ¸ã¿)ã«å¤æãã¦\
ã©ãã«ã¦ã£ã¸ã§ããã«æ¸¡ãã¦ããç¹ã«æ³¨æãã¦ãã ããï¼
EOL
#'
TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'éãã', :width=>15, :command=>proc{
$unicodeout_demo.destroy
$unicodeout_demo = nil
}).pack(:side=>:left, :expand=>true)
TkButton.new(f, :text=>'ã³ã¼ãåç
§', :width=>15, :command=>proc{
showCode 'unicodeout'
}).pack(:side=>:left, :expand=>true)
}
wait_msg = TkLabel.new(base_frame,
:text=>"ãã©ã³ãèªã¿è¾¼ã¿ã®å®äºã¾ã§" +
"ãã°ãããå¾
ã¡ä¸ããï¼ï¼ï¼",
:font=>"Helvetica 12 italic").pack
class Unicodeout_SampleFrame < TkFrame
@@font = $font
# @@font = 'Helvetica 14'
# @@font = 'Courier 12'
# @@font = 'clearlyu 16'
# @@font = 'fixed 12'
# @@font = 'Times 12'
# @@font = 'Newspaper 12'
# @@font = '{New century schoolbook} 12'
def initialize(base)
super(base)
grid_columnconfig(1, :weight=>1)
end
def add_sample(lang, *args)
sample_txt = Tk::UTF8_String(args.join(''))
l = TkLabel.new(self, :font=>@@font, :text=>lang+':',
:anchor=>:nw, :pady=>0)
#s = TkLabel.new(self, :font=>@@font, :text=>sample_txt,
s = TkLabel.new(self, :font=>TkFont.new(@@font), :text=>sample_txt,
:anchor=>:nw, :width=>30, :pady=>0)
Tk.grid(l, s, :sticky=>:ew, :pady=>0)
l.grid_config(:padx, '1m')
end
end
f = Unicodeout_SampleFrame.new(base_frame)
f.pack(:expand=>true, :fill=>:both, :padx=>'2m', :pady=>'1m')
# Processing when some characters are missing might take a while, so make
# sure we're displaying something in the meantime...
oldCursor = $unicodeout_demo.cursor
$unicodeout_demo.cursor('watch')
Tk.update
f.add_sample('Arabic',
'\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94',
'\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D')
f.add_sample('Trad. Chinese', '\u4E2D\u570B\u7684\u6F22\u5B57')
f.add_sample('Simpl. Chinese', '\u6C49\u8BED')
f.add_sample('Greek',
'\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE ',
'\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1')
f.add_sample('Hebrew',
'\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 ',
'\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9')
f.add_sample('Japanese',
'\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, ',
'\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA')
f.add_sample('Korean', '\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00')
f.add_sample('Russian',
'\u0420\u0443\u0441\u0441\u043A\u0438\u0439 ',
'\u044F\u0437\u044B\u043A')
wait_msg.destroy
$unicodeout_demo.cursor(oldCursor)
|