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
|
# -*- coding: utf-8 -*-
#
# radiobutton widget demo (called by 'widget')
#
# toplevel widget ãåå¨ããã°åé¤ãã
if defined?($radio_demo) && $radio_demo
$radio_demo.destroy
$radio_demo = nil
end
# demo ç¨ã® toplevel widget ãçæ
$radio_demo = TkToplevel.new {|w|
title("Radiobutton Demonstration")
iconname("radio")
positionWindow(w)
}
base_frame = TkFrame.new($radio_demo).pack(:fill=>:both, :expand=>true)
# label çæ
msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
text "ä¸ã«ã¯2ã¤ã®ã©ã¸ãªãã¿ã³ã°ã«ã¼ãã表示ããã¦ãã¾ãããã¿ã³ãã¯ãªãã¯ããã¨ããã®ãã¿ã³ã ãããã®ã°ã«ã¼ãã®ä¸ã§é¸æããã¾ããåã°ã«ã¼ãã«å¯¾ãã¦ãã®ã°ã«ã¼ãã®ä¸ã®ã©ã®ãã¿ã³ãé¸æããã¦ãããã示ãå¤æ°ãå²ãå½ã¦ããã¦ãã¾ããç¾å¨ã®å¤æ°ã®å¤ãè¦ãã«ã¯ãå¤æ°åç
§ããã¿ã³ãã¯ãªãã¯ãã¦ãã ããã"
}
msg.pack('side'=>'top')
# å¤æ°çæ
size = TkVariable.new
color = TkVariable.new
# frame çæ
TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'äºè§£'
text 'éãã'
command proc{
tmppath = $radio_demo
$radio_demo = nil
$showVarsWin[tmppath.path] = nil
tmppath.destroy
}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text 'ã³ã¼ãåç
§'
command proc{showCode 'radio'}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text 'å¤æ°åç
§'
command proc{
showVars(base_frame, ['size', size], ['color', color])
}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame çæ
f_left = TkFrame.new(base_frame)
f_right = TkFrame.new(base_frame)
f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
# radiobutton çæ
[10, 12, 18, 24].each {|sz|
TkRadioButton.new(f_left) {
text "ãã¤ã³ããµã¤ãº #{sz}"
variable size
relief 'flat'
value sz
}.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
}
['赤', 'ç·', 'é', 'é»', 'æ©', 'ç´«'].each {|col|
TkRadioButton.new(f_right) {
text col
variable color
relief 'flat'
value col.downcase
}.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
}
|