1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* (bug fix) forgot to entry a widget class name of 'labelframe' widget

* add demo-scripts to the JP/EN widget demos


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagai 2003-08-02 09:58:13 +00:00
parent 08719ea238
commit 6277a66deb
12 changed files with 650 additions and 6 deletions

View file

@ -84,10 +84,13 @@ sample/demos-en/images/teapot.ppm
sample/demos-en/items.rb
sample/demos-en/ixset
sample/demos-en/label.rb
sample/demos-en/labelframe.rb
sample/demos-en/menu.rb
sample/demos-en/menubu.rb
sample/demos-en/msgbox.rb
sample/demos-en/patch_1.1c1
sample/demos-en/paned1.rb
sample/demos-en/paned2.rb
sample/demos-en/plot.rb
sample/demos-en/puzzle.rb
sample/demos-en/radio.rb
@ -97,6 +100,7 @@ sample/demos-en/rolodex-j
sample/demos-en/ruler.rb
sample/demos-en/sayings.rb
sample/demos-en/search.rb
sample/demos-en/spin.rb
sample/demos-en/square
sample/demos-en/states.rb
sample/demos-en/style.rb
@ -153,10 +157,13 @@ sample/demos-jp/images/teapot.ppm
sample/demos-jp/items.rb
sample/demos-jp/ixset
sample/demos-jp/label.rb
sample/demos-jp/labelframe.rb
sample/demos-jp/menu.rb
sample/demos-jp/menu8x.rb
sample/demos-jp/menubu.rb
sample/demos-jp/msgbox.rb
sample/demos-jp/paned1.rb
sample/demos-jp/paned2.rb
sample/demos-jp/plot.rb
sample/demos-jp/puzzle.rb
sample/demos-jp/radio.rb
@ -166,6 +173,7 @@ sample/demos-jp/rolodex-j
sample/demos-jp/ruler.rb
sample/demos-jp/sayings.rb
sample/demos-jp/search.rb
sample/demos-jp/spin.rb
sample/demos-jp/square
sample/demos-jp/states.rb
sample/demos-jp/style.rb

View file

@ -4271,6 +4271,9 @@ class TkFrame<TkWindow
end
class TkLabelFrame<TkFrame
TkCommandNames = ['labelframe'.freeze].freeze
WidgetClassName = 'Labelframe'.freeze
WidgetClassNames[WidgetClassName] = self
def create_self(keys)
if keys and keys != None
tk_call 'labelframe', @path, *hash_kv(keys)
@ -4279,6 +4282,7 @@ class TkLabelFrame<TkFrame
end
end
end
TkLabelframe = TkLabelFrame
class TkPanedWindow<TkWindow
TkCommandNames = ['panedwindow'.freeze].freeze

View file

@ -0,0 +1,93 @@
# labelframe.rb
#
# This demonstration script creates a toplevel window containing
# several labelframe widgets.
#
# based on "Id: labelframe.tcl,v 1.2 2001/10/30 11:21:50 dkf Exp"
if defined?($labelframe_demo) && $labelframe_demo
$labelframe_demo.destroy
$labelframe_demo = nil
end
$labelframe_demo = TkToplevel.new {|w|
title("Labelframe Demonstration")
iconname("labelframe")
positionWindow(w)
}
# Some information
TkLabel.new($labelframe_demo,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
Labelframes are used to group related widgets together. \
The label may be either plain text or another widget. \
If your Tk library linked to Ruby doesn't include a 'labelframe' widget, \
this demo doesn't work. Please use later version of Tk \
which supports a 'labelframe' widget.
EOL
# The bottom buttons
TkFrame.new($labelframe_demo){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
$labelframe_demo.destroy
$labelframe_demo = nil
}).pack(:side=>:left, :expand=>true)
TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
showCode 'labelframe'
}).pack(:side=>:left, :expand=>true)
}
# Demo area
w = TkFrame.new($labelframe_demo).pack(:side=>:bottom, :fill=>:both,
:expand=>true)
# A group of radiobuttons in a labelframe
TkLabelFrame.new(w, :text=>'Value',
:padx=>2, :pady=>2) {|f|
grid(:row=>0, :column=>0, :pady=>'2m', :padx=>'2m')
v = TkVariable.new
(1..4).each{|i|
TkRadiobutton.new(f, :text=>"This is value #{i}",
:variable=>v, :value=>i) {
pack(:side=>:top, :fill=>:x, :pady=>2)
}
}
}
# Using a label window to control a group of options.
$lfdummy = TkVariable.new(0)
def lfEnableButtons(w)
TkWinfo.children(w).each{|child|
next if child.path =~ /\.cb$/
if $lfdummy == 1
child.state(:normal)
else
child.state(:disabled)
end
}
end
TkLabelFrame.new(w, :pady=>2, :padx=>2){|f|
TkCheckButton.new(f, :widgetname=>'cb', :variable=>$lfdummy,
:text=>"Use this option.", :padx=>0) {|cb|
command proc{lfEnableButtons(f)}
f.labelwidget(cb)
}
grid(:row=>0, :column=>1, :pady=>'2m', :padx=>'2m')
%w(Option1 Option2 Option3).each{|str|
TkCheckbutton.new(f, :text=>str).pack(:side=>:top, :fill=>:x, :pady=>2)
}
lfEnableButtons(f)
}
TkGrid.columnconfigure(w, [0,1], :weight=>1)

View file

@ -0,0 +1,45 @@
# paned1.rb
#
# This demonstration script creates a toplevel window containing
# a paned window that separates two windows horizontally.
#
# based on "Id: paned1.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
if defined?($paned1_demo) && $paned1_demo
$paned1_demo.destroy
$paned1_demo = nil
end
$paned1_demo = TkToplevel.new {|w|
title("Horizontal Paned Window Demonstration")
iconname("paned1")
positionWindow(w)
}
TkLabel.new($paned1_demo,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
The sash between the two coloured windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)
If your Tk library linked to Ruby doesn't include a 'panedwindow', this demo doesn't work. Please use later version of Tk which supports a 'panedwindow'.
EOL
# The bottom buttons
TkFrame.new($paned1_demo){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
$paned1_demo.destroy
$paned1_demo = nil
}).pack(:side=>:left, :expand=>true)
TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
showCode 'paned1'
}).pack(:side=>:left, :expand=>true)
}
TkPanedwindow.new($paned1_demo){|f|
pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
add(TkLabel.new(f, :text=>"This is the\nleft side", :bg=>'yellow'),
TkLabel.new(f, :text=>"This is the\nright side", :bg=>'cyan'))
}

View file

@ -0,0 +1,92 @@
# paned2.rb --
#
# This demonstration script creates a toplevel window containing
# a paned window that separates two windows vertically.
#
# based on "Id: paned2.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
if defined?($paned2_demo) && $paned2_demo
$paned2_demo.destroy
$paned2_demo = nil
end
$paned2_demo = TkToplevel.new {|w|
title("Vertical Paned Window Demonstration")
iconname("paned2")
positionWindow(w)
}
TkLabel.new($paned2_demo,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
The sash between the two scrolled windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)
If your Tk library linked to Ruby doesn't include a 'panedwindow', this demo doesn't work. Please use later version of Tk which supports a 'panedwindow'.
EOL
# The bottom buttons
TkFrame.new($paned2_demo){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
$paned2_demo.destroy
$paned2_demo = nil
}).pack(:side=>:left, :expand=>true)
TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
showCode 'paned2'
}).pack(:side=>:left, :expand=>true)
}
paneList = TkVariable.new # define as normal variable (not array)
paneList.value = [ # ruby's array --> tcl's list
'List of Ruby/Tk Widgets',
'TkButton',
'TkCanvas',
'TkCheckbutton',
'TkEntry',
'TkFrame',
'TkLabel',
'TkLabelframe',
'TkListbox',
'TkMenu',
'TkMenubutton',
'TkMessage',
'TkPanedwindow',
'TkRadiobutton',
'TkScale',
'TkScrollbar',
'TkSpinbox',
'TkText',
'TkToplevel'
]
# Create the pane itself
TkPanedwindow.new($paned2_demo, :orient=>:vertical){|f|
pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
add(TkFrame.new(f){|paned2_top|
TkListbox.new(paned2_top, :listvariable=>paneList) {
# Invert the first item to highlight it
itemconfigure(0, :background=>self.cget(:foreground),
:foreground=>self.cget(:background) )
yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right,
:fill=>:y))
pack(:fill=>:both, :expand=>true)
}
},
TkFrame.new(f) {|paned2_bottom|
# The bottom window is a text widget with scrollbar
paned2_xscr = TkScrollbar.new(paned2_bottom)
paned2_yscr = TkScrollbar.new(paned2_bottom)
paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) {
insert('1.0', "This is just a normal text widget")
xscrollbar(paned2_xscr)
yscrollbar(paned2_yscr)
}
Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew')
Tk.grid(paned2_xscr, :sticky=>'nsew')
TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1)
TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1)
} )
}

View file

@ -0,0 +1,64 @@
# spin.rb --
#
# This demonstration script creates several spinbox widgets.
#
# based on Tcl/Tk8.4.4 widget demos
if defined?($spin_demo) && $spin_demo
$spin_demo.destroy
$spin_demo = nil
end
$spin_demo = TkToplevel.new {|w|
title("Spinbox Demonstration")
iconname("spin")
positionWindow(w)
}
TkLabel.new($spin_demo,
:font=>$font, :wraplength=>'5i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
Three different spin-boxes are displayed below. \
You can add characters by pointing, clicking and typing. \
The normal Motif editing characters are supported, along with \
many Emacs bindings. For example, Backspace and Control-h \
delete the character to the left of the insertion cursor and \
Delete and Control-d delete the chararacter to the right of the \
insertion cursor. For values that are too large to fit in the \
window all at once, you can scan through the value by dragging \
with mouse button2 pressed. Note that the first spin-box will \
only permit you to type in integers, and the third selects from \
a list of Australian cities.
If your Tk library linked to Ruby doesn't include a 'spinbox' widget, \
this demo doesn't work. Please use later version of Tk \
which supports a 'spinbox' widget.
EOL
TkFrame.new($spin_demo){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
$spin_demo.destroy
$spin_demo = nil
}).pack(:side=>:left, :expand=>true)
TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
showCode 'spin'
}).pack(:side=>:left, :expand=>true)
}
australianCities = [
'Canberra', 'Sydney', 'Melbourne', 'Perth', 'Adelaide',
'Brisbane', 'Hobart', 'Darwin', 'Alice Springs'
]
[
# Current version of Ruby/Tk (current is 1.8.0) is not enough
# to support 'validate' option and related options. This problem
# will be improved in the next or future version.
TkSpinbox.new($spin_demo, :from=>1, :to=>10, :width=>10, :validate=>:key,
:validatecommand=>"string is integer %P"),
TkSpinbox.new($spin_demo, :from=>0, :to=>3, :increment=>0.5,
:format=>'%05.2f', :width=>10),
TkSpinbox.new($spin_demo, :values=>australianCities, :width=>10)
].each{|sbox| sbox.pack(:side=>:top, :pady=>5, :padx=>10)}

View file

@ -206,6 +206,8 @@ txt.insert('end', "7. Two labels displaying images.\n", tag_demo, "demo-image1")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "8. A simple user interface for viewing images.\n", tag_demo, "demo-image2")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "9. Labelled frames (if supported)\n", tag_demo, "demo-labelframe")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
txt.insert('end', "Listboxes\n", tag_title)
@ -218,13 +220,15 @@ txt.insert('end', "3. A collection of famous sayings.\n", tag_demo, "demo-saying
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
txt.insert('end', "Entries\n", tag_title)
txt.insert('end', "Entries and Spin-boxes\n", tag_title)
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "1. Without scrollbars.\n", tag_demo, "demo-entry1")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "2. With scrollbars.\n", tag_demo, "demo-entry2")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "3. Simple Rolodex-like form.\n", tag_demo, "demo-form")
txt.insert('end', "3. Spin-boxes. (if supported)\n", tag_demo, "demo-spin")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "4. Simple Rolodex-like form.\n", tag_demo, "demo-form")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
@ -267,6 +271,14 @@ txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "2. Horizontal scale.\n", tag_demo.id, "demo-hscale")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
txt.insert('end', "Paned Windows\n", tag_title)
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "1. Horizontal paned window. (if supported)\n", tag_demo.id, "demo-paned1")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "2. Vertical paned window. (if supported)\n", tag_demo.id, "demo-paned2")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
txt.insert('end', "Menus\n", tag_title)
txt.insert('end', " \n ", tag_demospace)
@ -490,7 +502,7 @@ end
#
def aboutBox
Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo',
'message'=>"Ruby/Tk widget demonstration Ver.1.0.2\n\n( based on Tk 8.1 Copyright (c) 1996-1997 Sun Microsystems, Inc. )\n\nRunning Version :: Ruby#{VERSION}/Tk#{$tk_version}")
'message'=>"Ruby/Tk widget demonstration Ver.1.3.0-en\n\n( based on Tk 8.1 Copyright (c) 1996-1997 Sun Microsystems, Inc. )\n\nRunning Version :: Ruby#{VERSION}/Tk#{$tk_version}")
end
################################

View file

@ -0,0 +1,98 @@
# labelframe.rb
#
# This demonstration script creates a toplevel window containing
# several labelframe widgets.
#
# based on "Id: labelframe.tcl,v 1.2 2001/10/30 11:21:50 dkf Exp"
if defined?($labelframe_demo) && $labelframe_demo
$labelframe_demo.destroy
$labelframe_demo = nil
end
$labelframe_demo = TkToplevel.new {|w|
title("Labelframe Demonstration")
iconname("labelframe")
positionWindow(w)
}
# Some information
TkLabel.new($labelframe_demo,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
TkLabelFrame widget
使
Ruby Tk
labelframe
labelframe
Tk
EOL
# The bottom buttons
TkFrame.new($labelframe_demo){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'了解', :width=>15, :command=>proc{
$labelframe_demo.destroy
$labelframe_demo = nil
}).pack(:side=>:left, :expand=>true)
TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{
showCode 'labelframe'
}).pack(:side=>:left, :expand=>true)
}
# Demo area
w = TkFrame.new($labelframe_demo).pack(:side=>:bottom, :fill=>:both,
:expand=>true)
# A group of radiobuttons in a labelframe
TkLabelFrame.new(w, :text=>'選択値',
:padx=>2, :pady=>2) {|f|
grid(:row=>0, :column=>0, :pady=>'2m', :padx=>'2m')
v = TkVariable.new
(1..4).each{|i|
TkRadiobutton.new(f, :text=>"This is value #{i}",
:variable=>v, :value=>i) {
pack(:side=>:top, :fill=>:x, :pady=>2)
}
}
}
# Using a label window to control a group of options.
$lfdummy = TkVariable.new(0)
def lfEnableButtons(w)
TkWinfo.children(w).each{|child|
next if child.path =~ /\.cb$/
if $lfdummy == 1
child.state(:normal)
else
child.state(:disabled)
end
}
end
TkLabelFrame.new(w, :pady=>2, :padx=>2){|f|
TkCheckButton.new(f, :widgetname=>'cb', :variable=>$lfdummy,
:text=>"オプションを使用", :padx=>0) {|cb|
command proc{lfEnableButtons(f)}
f.labelwidget(cb)
}
grid(:row=>0, :column=>1, :pady=>'2m', :padx=>'2m')
%w(オプション1 オプション2 オプション3).each{|str|
TkCheckbutton.new(f, :text=>str).pack(:side=>:top, :fill=>:x, :pady=>2)
}
lfEnableButtons(f)
}
TkGrid.columnconfigure(w, [0,1], :weight=>1)

View file

@ -0,0 +1,48 @@
# paned1.rb
#
# This demonstration script creates a toplevel window containing
# a paned window that separates two windows horizontally.
#
# based on "Id: paned1.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
if defined?($paned1_demo) && $paned1_demo
$paned1_demo.destroy
$paned1_demo = nil
end
$paned1_demo = TkToplevel.new {|w|
title("Horizontal Paned Window Demonstration")
iconname("paned1")
positionWindow(w)
}
TkLabel.new($paned1_demo,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
使
使 Ruby Tk panedwindow
panedwindow
Tk
EOL
# The bottom buttons
TkFrame.new($paned1_demo){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'了解', :width=>15, :command=>proc{
$paned1_demo.destroy
$paned1_demo = nil
}).pack(:side=>:left, :expand=>true)
TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{
showCode 'paned1'
}).pack(:side=>:left, :expand=>true)
}
TkPanedwindow.new($paned1_demo){|f|
pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
add(TkLabel.new(f, :text=>"This is the\nleft side", :bg=>'yellow'),
TkLabel.new(f, :text=>"This is the\nright side", :bg=>'cyan'))
}

View file

@ -0,0 +1,96 @@
# paned2.rb --
#
# This demonstration script creates a toplevel window containing
# a paned window that separates two windows vertically.
#
# based on "Id: paned2.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
if defined?($paned2_demo) && $paned2_demo
$paned2_demo.destroy
$paned2_demo = nil
end
$paned2_demo = TkToplevel.new {|w|
title("Vertical Paned Window Demonstration")
iconname("paned2")
positionWindow(w)
}
TkLabel.new($paned2_demo,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
使
使 Ruby Tk panedwindow
panedwindow
Tk
EOL
# The bottom buttons
TkFrame.new($paned2_demo){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'了解', :width=>15, :command=>proc{
$paned2_demo.destroy
$paned2_demo = nil
}).pack(:side=>:left, :expand=>true)
TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{
showCode 'paned2'
}).pack(:side=>:left, :expand=>true)
}
paneList = TkVariable.new # define as normal variable (not array)
paneList.value = [ # ruby's array --> tcl's list
'Ruby/Tk のウィジェット一覧',
'TkButton',
'TkCanvas',
'TkCheckbutton',
'TkEntry',
'TkFrame',
'TkLabel',
'TkLabelframe',
'TkListbox',
'TkMenu',
'TkMenubutton',
'TkMessage',
'TkPanedwindow',
'TkRadiobutton',
'TkScale',
'TkScrollbar',
'TkSpinbox',
'TkText',
'TkToplevel'
]
# Create the pane itself
TkPanedwindow.new($paned2_demo, :orient=>:vertical){|f|
pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
add(TkFrame.new(f){|paned2_top|
TkListbox.new(paned2_top, :listvariable=>paneList) {
# Invert the first item to highlight it
itemconfigure(0, :background=>self.cget(:foreground),
:foreground=>self.cget(:background) )
yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right,
:fill=>:y))
pack(:fill=>:both, :expand=>true)
}
},
TkFrame.new(f) {|paned2_bottom|
# The bottom window is a text widget with scrollbar
paned2_xscr = TkScrollbar.new(paned2_bottom)
paned2_yscr = TkScrollbar.new(paned2_bottom)
paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) {
insert('1.0', 'ここに配置されているのは、' +
'ごく普通のテキストウィジェットです。')
xscrollbar(paned2_xscr)
yscrollbar(paned2_yscr)
}
Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew')
Tk.grid(paned2_xscr, :sticky=>'nsew')
TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1)
TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1)
} )
}

View file

@ -0,0 +1,68 @@
# spin.rb --
#
# This demonstration script creates several spinbox widgets.
#
# based on Tcl/Tk8.4.4 widget demos
if defined?($spin_demo) && $spin_demo
$spin_demo.destroy
$spin_demo = nil
end
$spin_demo = TkToplevel.new {|w|
title("Spinbox Demonstration")
iconname("spin")
positionWindow(w)
}
TkLabel.new($spin_demo,
:font=>$font, :wraplength=>'5i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
\
Emacs
Motif
Backspace Control-h
Delete Control-d
使 Ruby Tk
spinbox
spinbox
Tk
EOL
TkFrame.new($spin_demo){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'了解', :width=>15, :command=>proc{
$spin_demo.destroy
$spin_demo = nil
}).pack(:side=>:left, :expand=>true)
TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{
showCode 'spin'
}).pack(:side=>:left, :expand=>true)
}
australianCities = [
'Canberra', 'Sydney', 'Melbourne', 'Perth', 'Adelaide',
'Brisbane', 'Hobart', 'Darwin', 'Alice Springs'
]
[
# 現状の Ruby/Tk (現在のバージョンは 1.8.0) では、validate オプションや
# それに関連するオプションへのサポートを十分に達成できていません。この
# 問題については、次または将来のバージョンで改善する予定です。
TkSpinbox.new($spin_demo, :from=>1, :to=>10, :width=>10, :validate=>:key,
:validatecommand=>"string is integer %P"),
TkSpinbox.new($spin_demo, :from=>0, :to=>3, :increment=>0.5,
:format=>'%05.2f', :width=>10),
TkSpinbox.new($spin_demo, :values=>australianCities, :width=>10)
].each{|sbox| sbox.pack(:side=>:top, :pady=>5, :padx=>10)}

View file

@ -223,6 +223,9 @@ txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "8. 画像を見るための簡単なユーザインターフェース\n",
tag_demo, "demo-image2")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "9. ラベル付きフレーム (Tkに実装されている場合に限る)\n",
tag_demo, "demo-labelframe")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
#txt.insert('end', "リストボックス\n", tag_middle)
@ -237,14 +240,17 @@ txt.insert('end', "3.
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
#txt.insert('end', "エントリ\n", tag_middle)
#txt.insert('end', "エントリとスピンボックス\n", tag_middle)
txt.insert('end', "エントリ\n", tag_kanji_title)
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "1. スクロールバーなし\n", tag_demo, "demo-entry1")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "2. スクロールバーあり\n", tag_demo, "demo-entry2")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "3. 簡単なフォーム\n", tag_demo, "demo-form")
txt.insert('end', "3. スピンボックス (Tkに実装されている場合に限る)\n",
tag_demo, "demo-spin")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "4. 簡単なフォーム\n", tag_demo, "demo-form")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
@ -293,6 +299,16 @@ txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "2. 水平\n", tag_demo.id, "demo-hscale")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
txt.insert('end', "ペインドウィンドウ\n", tag_kanji_title)
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "1. 水平方向 (Tkに実装されている場合に限る)\n",
tag_demo.id, "demo-paned1")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "2. 垂直方向 (Tkに実装されている場合に限る)\n",
tag_demo.id, "demo-paned2")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
#txt.insert('end', "メニュー\n", tag_middle)
txt.insert('end', "メニュー\n", tag_kanji_title)
@ -496,7 +512,7 @@ end
#
def aboutBox
Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo',
'message'=>"Ruby/Tk ウィジェットデモ Ver.1.2.2\n\n( based on Tk ウィジェットデモ :: Copyright (c) 1996-1997 Sun Microsystems, Inc. )\n\nRunning Version :: Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''}")
'message'=>"Ruby/Tk ウィジェットデモ Ver.1.3.0-jp\n\n( based on Tk ウィジェットデモ :: Copyright (c) 1996-1997 Sun Microsystems, Inc. )\n\nRunning Version :: Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''}")
end
################################