blob: 000fcb5091196329f839aca46686565fa4a9c11e (
plain)
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
|
# -*- coding: utf-8 -*-
#
# form widget demo (called by 'widget')
#
# toplevel widget ãåå¨ããã°åé¤ãã
if defined?($form_demo) && $form_demo
$form_demo.destroy
$form_demo = nil
end
# demo ç¨ã® toplevel widget ãçæ
$form_demo = TkToplevel.new {|w|
title("Form Demonstration")
iconname("form")
positionWindow(w)
}
base_frame = TkFrame.new($form_demo).pack(:fill=>:both, :expand=>true)
# label çæ
msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
text "ãã®ã¦ã£ã³ãã¦ã¯ç°¡åãªãã©ã¼ã å
¥åç¨ã«ãªã£ã¦ãã¦ããã¾ãã¾ãªã¨ã³ããªã«å
¥åãã§ãã¾ããã¿ãã§ã¨ã³ããªã®åæ¿ããã§ãã¾ãã"
}
msg.pack('side'=>'top', 'fill'=>'x')
# frame çæ
TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'äºè§£'
text 'éãã'
command proc{
tmppath = $form_demo
$form_demo = nil
tmppath.destroy
}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text 'ã³ã¼ãåç
§'
command proc{showCode 'form'}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# entry çæ
form_data = []
(1..5).each{|i|
f = TkFrame.new(base_frame, 'bd'=>2)
e = TkEntry.new(f, 'relief'=>'sunken', 'width'=>40)
l = TkLabel.new(f)
e.pack('side'=>'right')
l.pack('side'=>'left')
form_data[i] = {'frame'=>f, 'entry'=>e, 'label'=>l}
}
# æååè¨å®
form_data[1]['label'].text('åå:')
form_data[2]['label'].text('ä½æ:')
form_data[5]['label'].text('é»è©±:')
# pack
(1..5).each{|i| form_data[i]['frame'].pack('side'=>'top', 'fill'=>'x')}
|