require 'tkmove3.rb' include TestBed TkRoot.new{ title 'find_withtag' } c = TkCanvas.new.pack testbed( c ) msg = TkMessage.new(nil, 'width'=>300).pack f1 = TkFrame.new.pack TkLabel.new(f1, 'text'=>'tag name: ').pack('side'=>'left') ent = TkEntry.new(f1, 'width'=>20).pack('side'=>'left') ent.insert(0, 'test_tag') f2 = TkFrame.new.pack TkButton.new(f2, 'text'=>'addtag_withtag', 'command'=>proc{ c.bind('B1-Motion', proc{}) tag = ent.value if tag != '' c.bind('1', proc{ c.addtag_withtag( tag, 'current' ) }) end }).pack('side'=>'left') TkButton.new(f2, 'text'=>'find_withtag', 'command'=>proc{ c.bind('B1-Motion', proc{}) tag = ent.value items = c.find_withtag( tag ) if items != [] message = '' items.each{|item| message += item.tags.inspect + "\n"} msg.text( message.chop ) items.each{|item| item.fill('blue')} end }).pack('side'=>'left') Tk.mainloop