Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > tk/listboxライブラリ > TkListboxクラス

class TkListbox

クラスの継承リスト: TkListbox < TkListItemConfig < TkItemConfigMethod < TkUtil < TkTreatItemFont < TkItemFontOptkeys < TkItemConfigOptkeys < TkUtil < Tk::Scrollable < Tk::X_Scrollable < Tk::Y_Scrollable < TkTextWin < TkWindow < TkObject < Tk < TkCore < TkComm < TkUtil < TkEvent < TkConfigMethod < TkUtil < TkTreatFont < TkBindCore < TkKernel < Object < Kernel < BasicObject

要約

リストボックスウィジェットのクラスです。 リストボックスウィジェットは項目の一覧を表すウィジェットです。

require "tk"
list = TkListbox.new { setgrid 'yes'; pack }
list.insert 'end', "abc"
list.insert 'end', "def"
list.insert 'end', "123"
list.insert 'end', "456"
Tk.mainloop

メソッドの説明の中で((*位置*))は、以下のいずれかを指します。

*数字

 数字で指定した要素位置(上端は0)

*"@x,y"

 x、y は数字です。
 数字で指定したピクセル位置(入力欄の左上端は0から始まる)

*"active"

 アクティブ(カーソル位置のこと)である要素の位置

*"end"

 最後の要素の位置

*"anchor"

 ???

インスタンスメソッド

定義 説明
activate(y)

((|y|))で指定した((*位置*))の要素をアクティブにします。そのリスト ボックスに((<入力フォーカス>))があれば、アクティブな行には下線が引 かれます。

clear
erase
curselection

((<選択>))された要素の要素番号を配列にして返します(要素番号は上端が0)

get(index)
get(first, last)

引数が1つの場合、指定した((*位置*))の要素を文字列で返します。 引数が2つの場合、指定した範囲の要素を文字列の配列で返します。

index(idx)
nearest(y)

((|y|))で指定したY座標に近い要素の要素番号を返します。

selection_anchor(index)

((|index|))で指定した((*位置*))の要素を((<アンカー>))にします。

selection_clear(first, last = Tk::None)

((|first|))、((|last|))で指定した((*位置*))の範囲の要素が((<選択>))さ れていれば非選択にします。((|last|))を省略した場合、((|first|))の((*位 置*))の要素を非選択にします。

selection_includes(index)

(({index}))で指定した((*位置*))の要素が((<選択>))されているかどうかを 真偽値(({true}))/(({false}))で返します。

selection_set(first, last = Tk::None)

((|first|))、((|last|))で指定した((*位置*))の範囲の要素を((<選択>))し ます。((|last|))を省略した場合、((|first|))の((*位置*))の要素を選択し ます。

size

要素の数を返します。

tagid(id)
value
value=(vals)

定数

定義 説明
TkCommandNames
WidgetClassName

継承したメソッド

! != == === =~ __id__ __send__ _dump class clone dclone display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy inspect instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method methods must_be must_be_close_to must_be_empty must_be_instance_of must_be_kind_of must_be_nil must_be_same_as must_be_within_epsilon must_equal must_include must_match must_raise must_respond_to must_send must_throw nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? respond_to_missing? singleton_class singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_a to_ary to_hash to_int to_io to_proc to_regexp to_s to_str to_yaml to_yaml_properties to_yaml_style trust untaint untrust untrusted? wont_be wont_be_close_to wont_be_empty wont_be_instance_of wont_be_kind_of wont_be_nil wont_be_same_as wont_be_within_epsilon wont_equal wont_include wont_match wont_respond_to root update ::AUTO_PATH ::JAPANIZED_TK ::LIBRARY_PATH ::PACKAGE_PATH ::TCL_LIBRARY_PATH ::TCL_MAJOR_VERSION ::TCL_MINOR_VERSION ::TCL_PACKAGE_PATH ::TCL_PATCHLEVEL ::TCL_PRECISION ::TCL_VERSION ::TK_MAJOR_VERSION ::TK_MINOR_VERSION ::TK_PATCHLEVEL ::TK_VERSION ::Tkextlib_RELEASE_DATE autoscroll unautoscroll bind bind_append bind_remove bindinfo bind bind_all bind_append bind_append_all bind_remove bind_remove_all bindinfo bindinfo_all subst ::GET_CONFIGINFO_AS_ARRAY ::GET_CONFIGINFOwoRES_AS_ARRAY ::TkExtlibAutoloadModule ::Tk_CMDTBL ::Tk_IDs ::Tk_WINDOWS ::USE_TCLs_LIST_FUNCTIONS ::WidgetClassNames [] []= __confinfo_cmd __conv_keyonly_opts cget config_hash_kv configinfo configure configure_cmd current_configinfo _tk_call_to_list_core after after_cancel after_idle appname appsend appsend_deny appsend_displayof callback_break callback_continue callback_return chooseColor chooseDirectory do_one_event event_generate getMultipleOpenFile getMultipleSaveFile getOpenFile getSaveFile get_eventloop_tick get_eventloop_weight get_no_event_wait inactive inactive_displayof info ip_eval ip_eval_with_enc ip_eval_without_enc ip_invoke ip_invoke_with_enc ip_invoke_without_enc is_mainloop? load_cmd_on_ip mainloop mainloop_exist? mainloop_thread? mainloop_watchdog messageBox rb_appsend rb_appsend_displayof reset_inactive reset_inactive_displayof restart scaling scaling_displayof set_eventloop_ticktimer_tick set_eventloop_weight set_no_event_wait tk_call tk_call_to_list tk_call_to_list_with_enc tk_call_to_list_without_enc tk_call_to_simplelist tk_call_to_simplelist_with_enc tk_call_to_simplelist_without_enc tk_call_with_enc tk_call_without_enc windowingsystem ::EventFlag ::INTERP ::WIDGET_DESTROY_HOOK install_bind install_bind_for_event_class current_itemconfiginfo itemcget itemconfiginfo itemconfigure epath method_missing path tk_send tk_send_to_list tk_send_to_list_with_enc tk_send_to_list_without_enc tk_send_to_simplelist tk_send_to_simplelist_with_enc tk_send_to_simplelist_without_enc tk_send_with_enc tk_send_without_enc to_eval bbox delete insert scan_dragto scan_mark see ::TkCommnadNames asciifont_configure asciifont_copy font_configinfo font_configure font_copy kanjifont_configure kanjifont_copy _conv_args _fromUTF8 _get_eval_enc_str _get_eval_string _symbolkey2str _toUTF8 bool hash_kv num_or_str number string ::None ::RELEASE_DATE bind_class bindtags bindtags= bindtags_shift bindtags_unshift caret colormodel command current_grab database_class database_classname destroy eventloop_tkwait eventloop_tkwait_destroy exist? focus grab grab_release grab_set grab_set_global grab_status grid grid_bbox grid_columnconfig grid_columnconfiginfo grid_config grid_forget grid_in grid_info grid_location grid_propagate grid_remove grid_rowconfig grid_rowconfiginfo grid_size grid_slaves lower pack pack_config pack_forget pack_in pack_info pack_propagate pack_slaves place place_config place_configinfo place_forget place_in place_info place_slaves raise thread_tkwait thread_tkwait_destroy tkwait tkwait_destroy .database_class .database_classname .new .to_eval