[Tk] Bug on TkBindTag.new_by_name ?

  • Thread starter email55555 email55555
  • Start date
E

email55555 email55555

It seems to me that there is a bug on TkBindTag.new_by_name.
Here is an example:

# The action on new_by_name has no effect ?! bug ?
require 'tk'
TkBindTag.new_by_name('My_BindTag', 'Button') {|e| puts 'OK'}
TkLabel.new:)text=>:Test).pack.bindtags = ['My_BandTag']
Tk.mainloop

However, this works:
require 'tk'
b = TkBindTag.new_by_name('My_BindTag')
b.bind('Button') {|e| puts 'OK'}
TkLabel.new:)text=>:Test).pack.bindtags = ['My_BandTag']
Tk.mainloop

By looking on the source code of TkBindTag, it seems on the new_by_name:
BTagID_TBL.delete @id ==> also delete the old action
the new one just has its name but no action associate to it.
That is maybe why the new_by_name action has no effect.
This seems a bug ?

Thanks.
 
H

Hidetoshi NAGAI

Hi,

From: email55555 email55555 <[email protected]>
Subject: [Tk] Bug on TkBindTag.new_by_name ?
Date: Wed, 15 Dec 2004 10:02:11 +0900
Message-ID: said:
It seems to me that there is a bug on TkBindTag.new_by_name.
Here is an example: (snip)
This seems a bug ?

Yes. You are right.
Please replace TkBindTag.new_by_name to the following.
-----------------------------------------------------
def TkBindTag.new_by_name(name, *args, &b)
return BTagID_TBL[name] if BTagID_TBL[name]
self.new.instance_eval{
BTagID_TBL.delete @id
@id = name
BTagID_TBL[@id] = self
bind(*args, &b) if args != []
}
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Ruby/Tk 10
Bug with Ruby/Tk encoding (ruby-1.9.1-rc1) 6
Tk : non blocking Tk.mainloop 20
Tk supports only GIF? 5
how can i get the text of entry in TK? 2
Ruby/Tk: How to colorize a Treeview? 2
A Tk window 20
Ruby/Tk 4

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top