From: Ronald Fischer Date: 2006-08-08T15:45:10+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: Re: Ruby/Tk : How to show tooltips (please correct my ugly > implementation) > Date: Mon, 7 Aug 2006 19:45:21 +0900 > Message-ID: <1154947375.72@user.newsoffice.de> >> 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?). > Hmm... Then you have to give attention the position of the > toplevel widget. If it is placed under the mouse cursor, > you'll see the flicker of the toplevel widget. I see the flicker, because as soon as the toplevel widget (my help-tooltip) is displayed, the underlying text field looses focus and the tooltip is destroyed. Did I understand this correct? This means that on creation of the tooltip toplevel widget, I need to specify that it is located a few pixel off the mouse cursor. I have used the algorith in the tkballonhelp example for this. >> what it actually does. (In particular, I did not understand >> the reason for the variables @path and @epath). > @path is a widget path which used on many of Tcl/Tk commands > except geometry manager commands. > @epath is used for geometry manager commands. This means that other Tk classes (such as the geometry manager) expect those variables to exist? Because in the example, I haven't seen any actual use for them. >> Could you please show me what I did wrong? > Where is `initialize' method? > When did you set the value of @self, @frame and @label? > On your code, @self is an uninitialized instance variable. You are right! Two mistakes made in one here. First, I had intended to use "self", not "@self". Second, I now realize that the parent is not my class, but the field for the tooltip, so it must be parent=@field1. Also, I forgot to rename the variables @frame and @label (copied from the balloon example) to @hw and @field1 (which are used in my version). Thank you for pointing this out. So this example works now. Thank you very much for helping. The only unsolved problem is that I am still using a TkLabel for the balloon text. As I mentioned in my original posting, I am looking for a widget which I can give an arbitrary size, and which formats multi-line text (i.e. arranging for line breaks automatically). The closest thing I have found so far, was a TkText, but this is a text entry field, and I don't want the user to allow to edit the displayed text. Do you have a suggestion of what Tk widget I could use for this? Ronald -- Ronald Fischer Posted via http://www.newsoffice.de/