Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

TCL(Tool Command Language) Scripting

tklib tooltips don't work on menu items?


I am trying to get tooltips on menu items using the tklib tooltip
package. In this I have been unsuccessful - nothing shows up.
I see that this issue was discussed here before:
http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/2f7...
As I understand it, the upshot of that it should work. The problem
referred to in that thread is on MS Windows. I am using Linux. So, do
tooltips work on menu items? Here is an example, based on the previous
thread:

package require Tk
package require tooltip

label .l -text "Label"
pack .l
tooltip::tooltip .l "Some 'tooltip' help"
set mb [menu .mb]
set m [menu $mb.file]
. config -menu $mb
$mb add cascade -label "File" -menu $m
$m add command -label "Save" -command {file_save}
tooltip::tooltip $m -index 1 "Save buffer contents"

The tooltip appears as intended over the label "Label", but not over
the "Save" item, either in situ or when torn off.

billpo@alum.mit.edu schrieb:

It should work, if it does not its a bug, please report a bug at the
sourceforge bug tracker for tcllib/tklib.

You could try if it works if you specify the -label value as -index
argument.

tooltip::tooltip $m -index "Save" "Save buffer contents"

Michael

The following works for me on unix:

package require Tk
package require tooltip

label .l -text "Label"
pack .l
tooltip::tooltip .l "Some 'tooltip' help"

menubutton .file -text "File" -menu .file.m  -underline 0
tooltip::tooltip .file "File menu"
pack .file
menu .file.m -tearoff 0
.file.m add command -label "Open"
tooltip::tooltip .file.m -index 0 "Open file"
.file.m add command -label "Save"
tooltip::tooltip .file.m -index 1 "Save file"

Hope that helps
Ivan...

On May 18, 8:32 am, Ivan Young <i@jet.uk> wrote:

This works for me too. Thanks. Now why the one way doesn't work and
this does, I must still puzzle out.
If you start with a menubutton, tooltips work as expected:

menubutton .menunobar -text "Menubutton" -menu .menunobar.m
pack .menunobar
menu .menunobar.m
.menunobar.m add command -label "Push" -command {puts stderr Pushed}
tooltip::tooltip .menunobar  "tooltip 1";#works
tooltip::tooltip .menunobar.m "tooltip 2";#does nothing
tooltip::tooltip .menunobar.m  -index 1 "tooltip 3";# works

If, however, you start with a menu, they don't work:

menu .menubar
.menubar add cascade -label "File" -menu [menu .menubar.file]
. configure -menu .menubar
.menubar.file add command -label "Open"
tooltip::tooltip .menubar.file -index 1 "Open file"

This is independent of whether the menu is set as a menubar. The
tooltip does not appear if we do this:

menu .menunobar
.menunobar post 40 40
.menunobar add cascade -label "File" -menu [menu .menunobar.file]
.menunobar.file add command -label "Open"
tooltip::tooltip .menunobar.file -index 1 "Open file"

So, there isn't a problem for popup menus, but if we want to create a
menubar we seem to be stuck, unless we do it manually, the pre-Tk 8.0
way:

frame .mymenubar
pack .mymenubar -side top
menubutton .mymenubar.bA -text "Menubutton A" -menu .mymenubar.bA.m
menubutton .mymenubar.bB -text "Menubutton B" -menu .mymenubar.bB.m
pack .mymenubar.bA .mymenubar.bB -side left
menu .mymenubar.bA.m
.mymenubar.bA.m add command -label "Push" -command {puts stderr
Pushed}
tooltip::tooltip .mymenubar  "tooltip 1";#appears over button A after
it is pushed
tooltip::tooltip .mymenubar.bA "tooltip 2";#appears
tooltip::tooltip .mymenubar.bA.m "tooltip 3";#never appears
tooltip::tooltip .mymenubar.bA.m  -index 1 "tooltip 4";#works

So, does anybody know how to get tooltips on menu items descending
from a menubar? And what is the explanation for the observed
behaviour?

Here's an additional fact. If we take the same menu, starting with a
menu, and post it separately, the tooltips work:

package require Tk
package require tooltip

menu .mb
.mb add cascade -label "File" -menu [menu .mb.file]
.mb post 40 40
tooltip::tooltip .mb -index 1 "tooltip 1"
.mb.file add command -label "Open"
tooltip::tooltip .mb.file -index 1 "tooltip 2"

Both tooltips appear as expected.

Now replace the line ".mb post 40 40" with:

. configure -menu .mb

and neither tooltip appears.

DynamicHelp in BWidget purports to work with menu items descended from
a menubar and provides an example. When I try the example
in http://aspn.activestate.com/ASPN/docs/ActiveTcl/8.4/bwidget/DynamicHe...
it does not work. I am getting frustrated.

Bill

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc