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)
|