2003-08-02 05:58:13 -04:00
|
|
|
|
# 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)
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>ˤϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD>ԥ<EFBFBD><EFBFBD>ܥå<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>\
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>줾<EFBFBD>졢<EFBFBD>ޥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϥ<EFBFBD><EFBFBD>뤳<EFBFBD>Ȥ<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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EFBFBD><EFBFBD><EFBFBD>ʤ<EFBFBD><EFBFBD>Ϥ<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ξ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD> spinbox <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>褦<EFBFBD>ʤ<EFBFBD><EFBFBD>꿷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Tk
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Ȥ߹<EFBFBD><EFBFBD>碌<EFBFBD>ƻ<EFBFBD>褦<EFBFBD>ˤ<EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
EOL
|
|
|
|
|
|
|
|
|
|
TkFrame.new($spin_demo){|f|
|
|
|
|
|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
|
|
|
|
|
|
2004-05-01 12:09:54 -04:00
|
|
|
|
TkButton.new(f, :text=>'<27>Ĥ<EFBFBD><C4A4><EFBFBD>', :width=>15, :command=>proc{
|
2003-08-02 05:58:13 -04:00
|
|
|
|
$spin_demo.destroy
|
|
|
|
|
$spin_demo = nil
|
|
|
|
|
}).pack(:side=>:left, :expand=>true)
|
|
|
|
|
|
|
|
|
|
TkButton.new(f, :text=>'<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>', :width=>15, :command=>proc{
|
|
|
|
|
showCode 'spin'
|
|
|
|
|
}).pack(:side=>:left, :expand=>true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
australianCities = [
|
|
|
|
|
'Canberra', 'Sydney', 'Melbourne', 'Perth', 'Adelaide',
|
|
|
|
|
'Brisbane', 'Hobart', 'Darwin', 'Alice Springs'
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
TkSpinbox.new($spin_demo, :from=>1, :to=>10, :width=>10, :validate=>:key,
|
2003-08-03 18:07:47 -04:00
|
|
|
|
:validatecommand=>[
|
|
|
|
|
proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
|
|
|
|
|
]),
|
2003-08-02 05:58:13 -04:00
|
|
|
|
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)}
|