Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Text Widget menu

0 views
Skip to first unread message

MB

unread,
Jul 30, 2002, 11:47:36 PM7/30/02
to
Hi all,

I know this was asked before, but I can't find the article anymore.

How do you delete entries in a Text's popup menu? Not just the toplevel
entries (like File, Edit etc), but cascade entries as well.

I want to remove the 'File->Exit' entry without removing the whole 'File' menu.

Any ideas?

MB

Jack D

unread,
Jul 31, 2002, 1:33:36 AM7/31/02
to
"MB" <M...@AWIBBLE.UQ.NET.AU> wrote in message
news:3D475DD8...@AWIBBLE.UQ.NET.AU...

> Hi all,
>
> I know this was asked before, but I can't find the article anymore.

Searching google groups will likely turn up something :)

>
> How do you delete entries in a Text's popup menu? Not just the toplevel
> entries (like File, Edit etc), but cascade entries as well.
>
> I want to remove the 'File->Exit' entry without removing the whole 'File'
menu.
>
> Any ideas?

# Example of manipulating the text menu popup.

use Tk;
use strict;

my $mw=tkinit;
my $text=$mw->Text->pack;
my $textmenu=$text->menu;

#get the menu associated with 'File'
my $filemenu=$textmenu->entrycget('File',-menu);

#Delete the 'Exit' command
$filemenu->delete(0);

#Replace it with your own
$filemenu->insert(0,'command',-label=>'Press Me', -command=>sub{print "I was
pressed\n"});

#Get the menu associated with 'Edit'
my $editmenu=$textmenu->entrycget('Edit',-menu);

#Delete the 'Cut' command
$editmenu->delete('Cut');

MainLoop;


Jack


MB

unread,
Jul 31, 2002, 11:18:58 PM7/31/02
to
Thanks - that goes in my personal 'Info to remember' file :)

MB

0 new messages