1 # -*- coding: euc-jp -*-
5 # This demonstration script creates several combobox widgets.
7 # based on "Id: combo.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
9 if defined?($combo_demo) && $combo_demo
14 $combo_demo = TkToplevel.new {|w|
15 title("Combobox Demonstration")
20 base_frame = TkFrame.new($combo_demo).pack(:fill=>:both, :expand=>true)
22 Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'5i', :justify=>:left,
23 :text=><<EOL).pack(:side=>:top, :fill=>:x)
24 °Ê²¼¤Ç¤Ï3¼ïÎà¤Î¥³¥ó¥Ü¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡¥\
25 ºÇ½é¤Î¤â¤Î¤Ï¡¤¥¨¥ó¥È¥ê¥¦¥£¥¸¥§¥Ã¥È¤ÈƱ¤¸Íͤˡ¤\
26 ¥Ý¥¤¥ó¥È¤·¤¿¤ê¡¤¥¯¥ê¥Ã¥¯¤·¤¿¤ê¡¤¥¿¥¤¥×¤·¤¿¤ê¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡¥\
27 ¤Þ¤¿¡¤Return¥¡¼¤òÆþÎϤ¹¤ì¤Ð¸½ºß¤ÎÃͤ¬¥ê¥¹¥È¤ËÄɲ䵤졤\
28 ¥É¥í¥Ã¥×¥À¥¦¥ó¥ê¥¹¥È¤«¤éÁªÂò¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡¥\
29 ¢(²¼¸þ¤Ìð°õ)¥¡¼¤ò²¡¤·¤Æɽ¼¨¤µ¤ì¤¿¥ê¥¹¥È¤«¤é\
30 Ìð°õ¥¡¼¤Ç¾¤Î¸õÊä¤òÁª¤ó¤ÇReturn¥¡¼¤ò²¡¤»¤Ð¡¤ÃͤòÁªÂò¤Ç¤¤Þ¤¹¡¥\
31 2ÈÖÌܤΥ³¥ó¥Ü¥Ü¥Ã¥¯¥¹¤ÏÆÃÄê¤ÎÃͤ˸ÇÄꤵ¤ì¤Æ¤ª¤ê¡¤°ìÀÚÊѹ¹¤Ç¤¤Þ¤»¤ó¡¥\
32 3ÈÖÌܤΤâ¤Î¤Ï¥ª¡¼¥¹¥È¥é¥ê¥¢¤ÎÅԻԤΥɥí¥Ã¥×¥À¥¦¥ó¥ê¥¹¥È¤«¤é\
33 ÁªÂò¤¹¤ë¤³¤È¤À¤±¤¬²Äǽ¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡¥
37 firstValue = TkVariable.new
38 secondValue = TkVariable.new
39 ozCity = TkVariable.new
41 ## See Code / Dismiss buttons
42 Ttk::Frame.new(base_frame) {|frame|
43 sep = Ttk::Separator.new(frame)
44 Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
46 Ttk::Button.new(frame, :text=>'ÊÑ¿ô»²¾È',
47 :image=>$image['view'], :compound=>:left,
50 ['firstVariable', firstValue],
51 ['secondVariable', secondValue],
54 Ttk::Button.new(frame, :text=>'¥³¡¼¥É»²¾È',
55 :image=>$image['view'], :compound=>:left,
56 :command=>proc{showCode 'combo'}),
57 Ttk::Button.new(frame, :text=>'ÊĤ¸¤ë',
58 :image=>$image['delete'], :compound=>:left,
64 grid_columnconfigure(0, :weight=>1)
65 pack(:side=>:bottom, :fill=>:x)
68 frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
71 '¥¥ã¥ó¥Ù¥é', '¥·¥É¥Ë¡¼', '¥á¥ë¥Ü¥ë¥ó', '¥Ñ¡¼¥¹', '¥¢¥Ç¥ì¡¼¥É',
72 '¥Ö¥ê¥¹¥Ù¡¼¥ó', '¥Û¥Ð¡¼¥È', '¥À¡¼¥¦¥£¥ó', '¥¢¥ê¥¹ ¥¹¥×¥ê¥ó¥°¥¹'
76 secondValue.value = 'Êѹ¹ÉÔ²Ä'
77 ozCity.value = '¥·¥É¥Ë¡¼'
79 Tk.pack(Ttk::Labelframe.new(frame, :text=>'Fully Editable'){|f|
80 Ttk::Combobox.new(f, :textvariable=>firstValue){|b|
81 b.bind('Return', '%W'){|w|
82 w.values <<= w.value unless w.values.include?(w.value)
84 }.pack(:pady=>5, :padx=>10)
87 Ttk::LabelFrame.new(frame, :text=>'Disabled'){|f|
88 Ttk::Combobox.new(f, :textvariable=>secondValue, :state=>:disabled) .
89 pack(:pady=>5, :padx=>10)
92 Ttk::LabelFrame.new(frame, :text=>'Defined List Only'){|f|
93 Ttk::Combobox.new(f, :textvariable=>ozCity, :state=>:readonly,
94 :values=>australianCities) .
95 pack(:pady=>5, :padx=>10)
98 :side=>:top, :pady=>5, :padx=>10)