bearslumber has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I am trying to justify cascade entries within a menubar but every option I try does not seem to work and its driving me nuts.

I've tried packing each cascade and although this is accepted it has no effect. All the cascades are justified to the left regardless. I have previously used menubuttons directly on a normal frame and this allows justification of the buttons on the frame but I lose the automatic navigation (Alt+F etc) managed when using cascades.

Am I just being greedy and in fact I need to settle on one or the other?

Any help would be greatly appreciated.

Here is the code snippet procedure sub that defines the menu and cascades...

#--------------------------------------------------------------------- +-------------- #-- Define menubar sub Define_Menu { $Menu_Frame = $TopWindow->Frame(-relief => 'raised', -borderwidth = +> 2)->form(-top=>'%0',-left=>'%0',-right=>'%100'); $Menu_Toplevel = $Menu_Frame->toplevel ; $Menu_Bar = $Menu_Toplevel->Menu(-type => 'menubar') ; $Menu_Toplevel->configure(-menu => $Menu_Bar) ; $Menu_File = $Menu_Bar->cascade(-label=> '~File', -tearoff => 0); $Menu_File_Select = $Menu_File->command (-label => 'Select ~M +ySQL Dump File...', -command => \&Select_C +onfig_Root, -accelerator => 'Control+c +') ; $Menu_File->separator ; $Menu_File_Exit = $Menu_File->command (-label => '~Exit', -command => \&Abandon, -accelerator => 'Control+x') + ; $Menu_File->pack(-side=>'left',-anchor=>'nw') ; $Menu_Run = $Menu_Bar->cascade(-label=> '~Run', -tearoff => 0 ); $Menu_Run_Split = $Menu_Run->command (-label => '~Split', -command => \&Split , -accelerator => 'Control+q'); $Menu_Help = $Menu_Bar->cascade(-label=> '~Help', -tearoff => 0 ) ; $Menu_Help_Help = $Menu_Help->command (-label => '~Help', -command => [\&ShowHelpMess +age], -accelerator => 'Control+h') + ; $Menu_Help_About = $Menu_Help->command (-label => '~About', -command => [\&ShowAboutMe +ssage,$ver], -accelerator => 'Control+a' +) ; $Menu_Help->pack(-side=>'right',-anchor=>'ne') ; ; $Menu_Run_Split->configure(-state => 'disabled'); }

Replies are listed 'Best First'.
Re: Perl/TK Menubar can't justify cascades
by kubrat (Scribe) on Sep 16, 2008 at 12:11 UTC
    Have you got warnings turned on? There is a message about cascades being created automatically.
      Thank you Kubrat,

      I turned the warnings on and got the messages....

      Cannot 'pack' Tk::Menu::Cascade=ARRAY(0x3150fec) - done automatically +at line 169
      This implies that I can't justify the cascades using the pack routine. It also possibly also implies that the justification of cascades can't be manipulated.

      If the latter implication is true, then I guess I will not be able to manipulate the justification of a cascade. Tears are welling up in my eyes. At least I shall be able to manipulate these with my Hadkercheif. ;).

      If my reading between the lines is wrong and the justification can be achieved, possibly by other means; then I shall be very glad to receive some words of wisdom on how...

      Thanks again