Home > Archive > PerlTk > June 2007 > Balloon on menu items
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Balloon on menu items
|
|
| nishant 2007-06-14, 4:06 am |
| Hi ,
I am mtrying to atttach ballloon on the menu item but am not able to
do so.
Following is the program -
use strict ;
use Tk ;
my($mw, $menuBar, $balloon, $menu, $items, $label) ;
$mw = new MainWindow ;
$menuBar = $mw->Frame(-relief => 'raised',
-borderwidth => 1)->pack(-fill => 'x') ;
$items = [ [ 'command' => 'Open' ],
[ 'command' => 'Close' ],
[ 'command' => 'Save' ],
'-', # separator
[ 'command' => 'Quit', -command => sub { destroy $mw } ]
] ;
$menu = $menuBar->Menubutton(-text => 'File',
-menuitems => $items)->pack(-side =>
'left') ;
$balloon = $mw->Balloon(-balloonposition => 'mouse') ;
$balloon->attach($menu->cget(-menu),
-msg => [ undef, # a non message for the 'tear-off'
"Open a new file",
"Close the existing file",
"Save the open file",
undef, # a non message for the separator
"Quit and get me out of here" ]) ;
$items = [ [ 'command' => 'Cut' ],
[ 'command' => 'Copy' ],
[ 'command' => 'Paste' ],
'-',
[ 'command' => 'Undo' ]
] ;
$menu = $menuBar->Menubutton(-text => 'Edit',
-menuitems => $items)->pack(-side =>
'left') ;
$balloon->attach($menu->cget(-menu),
-msg => [ undef, # a non message for the 'tear-off'
"Cut the selected text\nto the clipboard",
"Copy the selected text\nto the clipboard",
"Paste text from the clipboard",
undef, # a non message for the separator
"Undo last change" ]) ;
$mw->Text->pack(-expand => 1, -fill => 'both') ;
MainLoop ;
| |
| QoS@domain.invalid 2007-06-15, 4:11 am |
|
nishant <nishant.031@gmail.com> wrote in message-id: <1181795545.312456.80750@i13g2000prf.googlegroups.com>
>
>Hi ,
>I am mtrying to atttach ballloon on the menu item but am not able to
>do so.
>Following is the program -
>
>use strict ;
>use Tk ;
>
>my($mw, $menuBar, $balloon, $menu, $items, $label) ;
>
>$mw = new MainWindow ;
>
>$menuBar = $mw->Frame(-relief => 'raised',
> -borderwidth => 1)->pack(-fill => 'x') ;
>
>$items = [ [ 'command' => 'Open' ],
> [ 'command' => 'Close' ],
> [ 'command' => 'Save' ],
> '-', # separator
> [ 'command' => 'Quit', -command => sub { destroy $mw } ]
> ] ;
>
>$menu = $menuBar->Menubutton(-text => 'File',
> -menuitems => $items)->pack(-side =>
>'left') ;
>
>$balloon = $mw->Balloon(-balloonposition => 'mouse') ;
>
>$balloon->attach($menu->cget(-menu),
> -msg => [ undef, # a non message for the 'tear-off'
> "Open a new file",
> "Close the existing file",
> "Save the open file",
> undef, # a non message for the separator
> "Quit and get me out of here" ]) ;
>
>$items = [ [ 'command' => 'Cut' ],
> [ 'command' => 'Copy' ],
> [ 'command' => 'Paste' ],
> '-',
> [ 'command' => 'Undo' ]
> ] ;
>
>$menu = $menuBar->Menubutton(-text => 'Edit',
> -menuitems => $items)->pack(-side =>
>'left') ;
>
>$balloon->attach($menu->cget(-menu),
> -msg => [ undef, # a non message for the 'tear-off'
> "Cut the selected text\nto the clipboard",
> "Copy the selected text\nto the clipboard",
> "Paste text from the clipboard",
> undef, # a non message for the separator
> "Undo last change" ]) ;
>
>$mw->Text->pack(-expand => 1, -fill => 'both') ;
>
>MainLoop ;
I think you will need to try and use the Subwidget methods to get to
the buttons inside the menus, then attach the balloon to the subwidget.
| |
|
|
|
|
|