~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to ext/tk/sample/demos-jp/radio2.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# radio2.rb
 
2
#
 
3
# This demonstration script creates a toplevel window containing
 
4
# several radiobutton widgets.
 
5
#
 
6
# radiobutton widget demo (called by 'widget')
 
7
#
 
8
 
 
9
# toplevel widget
 
10
if defined?($radio2_demo) && $radio2_demo
 
11
  $radio2_demo.destroy 
 
12
  $radio2_demo = nil
 
13
end
 
14
 
 
15
# demo toplevel widget
 
16
$radio2_demo = TkToplevel.new {|w|
 
17
  title("Radiobutton Demonstration 2")
 
18
  iconname("radio2")
 
19
  positionWindow(w)
 
20
}
 
21
 
 
22
# label 
 
23
msg = TkLabel.new($radio2_demo) {
 
24
  font $font
 
25
  wraplength '5i'
 
26
  justify 'left'
 
27
  text "���ˤ�3�ĤΥ饸���ܥ��󥰥롼�פ�ɽ������Ƥ��ޤ����ܥ���򥯥�å�����ȡ����Υܥ�����������Υ��롼�פ�������򤵤�ޤ����ƥ��롼�פ��Ф��Ƥ��Υ��롼�פ���ΤɤΥܥ������򤵤�Ƥ��뤫�򼨤��ѿ���������Ƥ��Ƥ��ޤ������ߤ��ѿ����ͤ򸫤�ˤϡ��ѿ����ȡץܥ���򥯥�å����Ƥ���������"
 
28
}
 
29
msg.pack('side'=>'top')
 
30
 
 
31
 
32
size = TkVariable.new
 
33
color = TkVariable.new
 
34
align = TkVariable.new
 
35
 
 
36
# frame 
 
37
TkFrame.new($radio2_demo) {|frame|
 
38
  TkButton.new(frame) {
 
39
    #text 'λ��'
 
40
    text '�Ĥ���'
 
41
    command proc{
 
42
      tmppath = $radio2_demo
 
43
      $radio2_demo = nil
 
44
      $showVarsWin[tmppath.path] = nil
 
45
      tmppath.destroy
 
46
    }
 
47
  }.pack('side'=>'left', 'expand'=>'yes')
 
48
 
 
49
  TkButton.new(frame) {
 
50
    text '�����ɻ���'
 
51
    command proc{showCode 'radio2'}
 
52
  }.pack('side'=>'left', 'expand'=>'yes')
 
53
 
 
54
  TkButton.new(frame) {
 
55
    text '�ѿ�����'
 
56
    command proc{
 
57
      showVars($radio2_demo, 
 
58
               ['size', size], ['color', color], ['compound', align])
 
59
    }
 
60
  }.pack('side'=>'left', 'expand'=>'yes')
 
61
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
 
62
 
 
63
# frame 
 
64
f_left  = TkLabelFrame.new($radio2_demo, 'text'=>'ʸ��������', 
 
65
                           'pady'=>2, 'padx'=>2)
 
66
f_mid   = TkLabelFrame.new($radio2_demo, 'text'=>'��', 
 
67
                           'pady'=>2, 'padx'=>2)
 
68
f_right = TkLabelFrame.new($radio2_demo, 'text'=>'�ӥåȥޥå�����', 
 
69
                           'pady'=>2, 'padx'=>2)
 
70
f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
 
71
f_mid.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
 
72
f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
 
73
 
 
74
# radiobutton 
 
75
[10, 12, 18, 24].each {|sz|
 
76
  TkRadioButton.new(f_left) {
 
77
    text "�ݥ���ȥ����� #{sz}"
 
78
    variable size
 
79
    relief 'flat'
 
80
    value sz
 
81
  }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x')
 
82
}
 
83
 
 
84
['��', '��', '��', '��', '��', '��'].each {|col|
 
85
  TkRadioButton.new(f_mid) {
 
86
    text col
 
87
    variable color
 
88
    relief 'flat'
 
89
    value col.downcase
 
90
    anchor 'w'
 
91
  }.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
 
92
}
 
93
 
 
94
label = TkLabel.new(f_right, 'text'=>'��٥�', 'bitmap'=>'questhead', 
 
95
                    'compound'=>'left')
 
96
label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
 
97
label.height(TkWinfo.reqheight(label))
 
98
abtn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a|
 
99
  lower = a.downcase
 
100
  TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat', 
 
101
                    'value'=>lower, 'indicatoron'=>0, 'width'=>7, 
 
102
                    'command'=>proc{label.compound(align.value)})
 
103
}
 
104
 
 
105
Tk.grid('x', abtn[0])
 
106
Tk.grid(abtn[1], label, abtn[2])
 
107
Tk.grid('x', abtn[3])