From: Ronald Fischer Date: 2006-08-07T19:45:21+09:00 Subject: Re: Ruby/Tk : How to show tooltips (please correct my ugly implementation) Hidetoshi NAGAI wrote as nagai@ai.kyutech.ac.jp on 07. Aug 2006: > From: Ronald Fischer > Subject: Ruby/Tk : How to show tooltips (please correct my ugly implementation) > > Date: Mon, 7 Aug 2006 18:35:19 +0900 > Message-ID: <1154943284.46@user.newsoffice.de> >> I would like to add kind of a "show tooltips" function to my >> application, >> which means that some piece of text should be shown when the mourse >> moves >> over a certain area. In my case, the "hot spot" area is a set of >> TkLabel. > Please see "tkballoonhelp.rb" in "ext/tk/sample" directory > of Ruby source archive. Arigatou Hidetoshi-san. I studied the tkballoonhelp.rb and in particular I read about the functions overrideredirect and transient, but I must admit that I did not fully understand how it works. Nevertheless I tried to adapt it to my case (the example uses a timer to show and hide the tooltip, while I am using Enter and Leave events - but these seem only minor differences, aren't they?). I used part of the logic in tkballoonhelp, well knowing that it is a bit dangerous to just copy some code without knowing what it actually does. (In particular, I did not understand the reason for the variables @path and @epath). Here is my solution: class TestForm @hw=nil @root = TkRoot.new() { title("rtktest:TestForm") } @field1 = TkLabel.new(@root, :text => "field1").pack(); @field1.bind("Enter", proc {|e| puts("Entering field1") parent=@self @hw=TkToplevel.new() @hw.withdraw @hw.overrideredirect(true) @hw.transient(TkWinfo.toplevel(parent)) @epath = @frame.path helptext=TkLabel.new(@hw,:text=>"This is an example helptext").pack(); @path = @label @hw.deiconify @hw.raise } ) ... } def epath @epath end When the label receives the focus, I get the error message "bad window path name", so this might be due to my misunderstanding (and misuse) of @path/@epath. Could you please show me what I did wrong? Ronald -- Ronald Fischer Posted via http://www.newsoffice.de/