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
|
# -*- coding: utf-8 -*-
#
# listbox widget demo 'states' (called by 'widget')
#
# toplevel widget ãåå¨ããã°åé¤ãã
if defined?($states_demo) && $states_demo
$states_demo.destroy
$states_demo = nil
end
# demo ç¨ã® toplevel widget ãçæ
$states_demo = TkToplevel.new {|w|
title("Listbox Demonstration (states)")
iconname("states")
positionWindow(w)
}
base_frame = TkFrame.new($states_demo).pack(:fill=>:both, :expand=>true)
# label çæ
msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
text "ä¸ã«ããã®ã¯é½éåºçåãå
¥ã£ãã¹ã¯ãã¼ã«ãã¼ä»ã®ãªã¹ãããã¯ã¹ã§ãããªã¹ããã¹ã¯ãã¼ã«ãããã®ã¯ã¹ã¯ãã¼ã«ãã¼ã§ãã§ãã¾ããããªã¹ãããã¯ã¹ã®ä¸ã§ãã¦ã¹ã®ãã¿ã³2(ä¸ãã¿ã³)ãæ¼ããã¾ã¾ãã©ãã°ãã¦ãã§ãã¾ãã"
}
msg.pack('side'=>'top')
# frame çæ
TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'äºè§£'
text 'éãã'
command proc{
tmppath = $states_demo
$states_demo = nil
tmppath.destroy
}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text 'ã³ã¼ãåç
§'
command proc{showCode 'states'}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame çæ
states_lbox = nil
TkFrame.new(base_frame, 'borderwidth'=>'.5c') {|w|
s = TkScrollbar.new(w)
states_lbox = TkListbox.new(w) {
setgrid 1
height 12
yscrollcommand proc{|first,last| s.set first,last}
}
s.command(proc{|*args| states_lbox.yview(*args)})
s.pack('side'=>'right', 'fill'=>'y')
states_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
ins_data = [
'æç¥','é森','ç§ç°','ç³å·','è¨å','岩æ','æåª',
'大å','大éª','岡山','æ²ç¸','é¦å·','鹿å
島','ç¥å¥å·',
'å²é','京é½','çæ¬','群馬','é«ç¥','å¼ç','ä½è³',
'æ»è³','é岡','å³¶æ ¹','åè','æ±äº¬','徳島','æ æ¨',
'é³¥å','å¯å±±','é·å´','é·é','å¥è¯','æ°æ½','å
µåº«',
'åºå³¶','ç¦äº','ç¦å²¡','ç¦å³¶','åæµ·é','ä¸é','å®®å',
'å®®å´','山形','å±±å£','山梨','åæå±±'
]
states_lbox.insert(0, *ins_data)
|