mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
99 lines
3.4 KiB
Ruby
99 lines
3.4 KiB
Ruby
|
# -*- coding: euc-jp -*-
|
|||
|
#
|
|||
|
# combo.rb --
|
|||
|
#
|
|||
|
# This demonstration script creates several combobox widgets.
|
|||
|
#
|
|||
|
# based on "Id: combo.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
|
|||
|
|
|||
|
if defined?($combo_demo) && $combo_demo
|
|||
|
$combo_demo.destroy
|
|||
|
$combo_demo = nil
|
|||
|
end
|
|||
|
|
|||
|
$combo_demo = TkToplevel.new {|w|
|
|||
|
title("Combobox Demonstration")
|
|||
|
iconname("combo")
|
|||
|
positionWindow(w)
|
|||
|
}
|
|||
|
|
|||
|
base_frame = TkFrame.new($combo_demo).pack(:fill=>:both, :expand=>true)
|
|||
|
|
|||
|
Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'5i', :justify=>:left,
|
|||
|
:text=><<EOL).pack(:side=>:top, :fill=>:x)
|
|||
|
<EFBFBD>ʲ<EFBFBD><EFBFBD>Ǥ<EFBFBD>3<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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FBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD>ȤʤäƤ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
EOL
|
|||
|
|
|||
|
## variables
|
|||
|
firstValue = TkVariable.new
|
|||
|
secondValue = TkVariable.new
|
|||
|
ozCity = TkVariable.new
|
|||
|
|
|||
|
## See Code / Dismiss buttons
|
|||
|
Ttk::Frame.new(base_frame) {|frame|
|
|||
|
sep = Ttk::Separator.new(frame)
|
|||
|
Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
|
|||
|
TkGrid('x',
|
|||
|
Ttk::Button.new(frame, :text=>'<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>',
|
|||
|
:image=>$image['view'], :compound=>:left,
|
|||
|
:command=>proc{
|
|||
|
showVars(base_frame,
|
|||
|
['firstVariable', firstValue],
|
|||
|
['secondVariable', secondValue],
|
|||
|
['ozCity', ozCity])
|
|||
|
}),
|
|||
|
Ttk::Button.new(frame, :text=>'<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>',
|
|||
|
:image=>$image['view'], :compound=>:left,
|
|||
|
:command=>proc{showCode 'combo'}),
|
|||
|
Ttk::Button.new(frame, :text=>'<27>Ĥ<EFBFBD><C4A4><EFBFBD>',
|
|||
|
:image=>$image['delete'], :compound=>:left,
|
|||
|
:command=>proc{
|
|||
|
$combo_demo.destroy
|
|||
|
$combo_demo = nil
|
|||
|
}),
|
|||
|
:padx=>4, :pady=>4)
|
|||
|
grid_columnconfigure(0, :weight=>1)
|
|||
|
pack(:side=>:bottom, :fill=>:x)
|
|||
|
}
|
|||
|
|
|||
|
frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
|
|||
|
|
|||
|
australianCities = [
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>٥<EFBFBD>', '<27><><EFBFBD>ɥˡ<C9A5>', '<27><><EFBFBD><EFBFBD><EFBFBD>ܥ<EFBFBD><DCA5><EFBFBD>', '<27>ѡ<EFBFBD><D1A1><EFBFBD>', '<27><><EFBFBD>ǥ졼<C7A5><ECA1BC>',
|
|||
|
'<27>֥ꥹ<D6A5>١<EFBFBD><D9A1><EFBFBD>', '<27>ۥС<DBA5><D0A1><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD>ꥹ <20><><EFBFBD>ץ<EFBFBD><D7A5><EFBFBD>'
|
|||
|
]
|
|||
|
|
|||
|
|
|||
|
secondValue.value = '<27>ѹ<EFBFBD><D1B9>Բ<EFBFBD>'
|
|||
|
ozCity.value = '<27><><EFBFBD>ɥˡ<C9A5>'
|
|||
|
|
|||
|
Tk.pack(Ttk::Labelframe.new(frame, :text=>'Fully Editable'){|f|
|
|||
|
Ttk::Combobox.new(f, :textvariable=>firstValue){|b|
|
|||
|
b.bind('Return', '%W'){|w|
|
|||
|
w.values <<= w.value unless w.values.include?(w.value)
|
|||
|
}
|
|||
|
}.pack(:pady=>5, :padx=>10)
|
|||
|
},
|
|||
|
|
|||
|
Ttk::LabelFrame.new(frame, :text=>'Disabled'){|f|
|
|||
|
Ttk::Combobox.new(f, :textvariable=>secondValue, :state=>:disabled) .
|
|||
|
pack(:pady=>5, :padx=>10)
|
|||
|
},
|
|||
|
|
|||
|
Ttk::LabelFrame.new(frame, :text=>'Defined List Only'){|f|
|
|||
|
Ttk::Combobox.new(f, :textvariable=>ozCity, :state=>:readonly,
|
|||
|
:values=>australianCities) .
|
|||
|
pack(:pady=>5, :padx=>10)
|
|||
|
},
|
|||
|
|
|||
|
:side=>:top, :pady=>5, :padx=>10)
|