| 1 |
#!/usr/local/bin/perl -w |
| 2 |
use Tk; |
| 3 |
use strict; |
| 4 |
|
| 5 |
my $TOP = MainWindow->new; |
| 6 |
|
| 7 |
my @menubuttons; |
| 8 |
foreach (qw/right/) { |
| 9 |
my $pos = ucfirst; |
| 10 |
my $menubutton = $TOP->Menubutton(qw/-underline 0 -relief raised/, |
| 11 |
-text => $pos, -direction => $_); |
| 12 |
push @menubuttons, $menubutton; |
| 13 |
my $menu = $menubutton->menu(qw/-type menubar -tearoff 0/); |
| 14 |
$menubutton->configure(-menu => $menu); |
| 15 |
$menubutton->command(-label => "$pos menu: first item", -command => |
| 16 |
sub {print "You selected the first item from the $pos menu.\n"}); |
| 17 |
$menubutton->command(-label => "$pos menu: second item", -command => |
| 18 |
sub {print "You selected the second item from the $pos menu.\n"}); |
| 19 |
} |
| 20 |
$menubuttons[0]->grid(qw/-row 0 -column 1 -sticky n/); |
| 21 |
|
| 22 |
MainLoop; |
| 23 |
|
| 24 |
__END__ |
| 25 |
========================================================================== |
| 26 |
This message was posted through the Stanford campus mailing list |
| 27 |
server. If you wish to unsubscribe from this mailing list, send the |
| 28 |
message body of "unsubscribe ptk" to [email protected] |
| 29 |
|
| 30 |
The same problem can be reproduced with original Tk8.4 and Tk8.5: |
| 31 |
|
| 32 |
menubutton .mb -text test |
| 33 |
pack .mb |
| 34 |
menu .mb.menu -type menubar |
| 35 |
.mb configure -menu .mb.menu |
| 36 |
|
| 37 |
$ wish8.4 /tmp/menubug.tk |
| 38 |
Tk_MoveToplevelWindow called with non-toplevel window |
| 39 |
zsh: 32762 abort (core dumped) wish8.4 /tmp/menubug.tk |
| 40 |
|
| 41 |
It is reported as |
| 42 |
https://sourceforge.net/tracker2/?func=detail&aid=2160206&group_id=12997&atid=112997 |