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
|
# -*- coding: utf-8 -*-
#
# label widget demo (called by 'widget')
#
# toplevel widget ãåå¨ããã°åé¤ãã
if defined?($label_demo) && $label_demo
$label_demo.destroy
$label_demo = nil
end
# demo ç¨ã® toplevel widget ãçæ
$label_demo = TkToplevel.new {|w|
title("Label Demonstration")
iconname("label")
positionWindow(w)
}
base_frame = TkFrame.new($label_demo).pack(:fill=>:both, :expand=>true)
# label çæ
msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
text "ä¸ã«ã¯5ã¤ã®ã©ãã«ã表示ããã¦ãã¾ããå·¦å´ã«ã¯ããã¹ãã©ãã«ã3ã¤ãããå³å´ã«ã¯ããããããã©ãã«ã¨ããã¹ãã©ãã«ãããã¾ããã©ãã«ã¨ããã®ã¯ãã¾ãé¢ç½ããã®ã§ã¯ããã¾ããããªããªãçºãã以å¤ä½ãã§ããªãããã§ãã"
}
msg.pack('side'=>'top')
# frame çæ
TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'äºè§£'
text 'éãã'
command proc{
tmppath = $label_demo
$label_demo = nil
tmppath.destroy
}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text 'ã³ã¼ãåç
§'
command proc{showCode 'label'}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# label demo ç¨ãã¬ã¼ã çæ
f_left = TkFrame.new(base_frame)
f_right = TkFrame.new(base_frame)
[f_left, f_right].each{|w| w.pack('side'=>'left', 'expand'=>'yes',
'padx'=>10, 'pady'=>10, 'fill'=>'both')}
# label çæ
[ TkLabel.new(f_left, 'text'=>'æåã®ã©ãã«'),
TkLabel.new(f_left, 'text'=>'2 çªç®ãã¡ãã£ã¨æµ®ãä¸ãããã¦ã¿ã¾ãã',
'relief'=>'raised'),
TkLabel.new(f_left, 'text'=>'3 çªç®ãæ²ãã§ãã¾ã ', 'relief'=>'sunken')
].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')}
# TkLabel.new(f_right) {
Tk::Label.new(f_right) {
bitmap('@' + [$demo_dir,'..','images','face.xbm'].join(File::Separator))
borderwidth 2
relief 'sunken'
}.pack('side'=>'top')
TkLabel.new(f_right) { text 'Tcl/Tk ææè
' }.pack('side'=>'top')
|