http://www.perlmonks.org?node_id=1060009


in reply to Re^3: TK Submenus
in thread TK Submenus

Hello HDB, $opsm is defined in the code below however the Add Manifest menu does not return to the Ops menu it needs to return to the Manifest Menu:

sub opsmgt { if ( !Exists( $opsm ) ) { $opsm = $mw->Toplevel(); $opsm->resizable(0,0); my $opsmframe2 = $opsm->Frame()->pack( -side => 'right', -fill => 'bo +th', -anchor, 'e'); my $opsmframe = $opsm->Frame()->pack( -side => 'left', -fill => 'bo +th', -anchor, 'w'); $opsm->geometry('400x125+0+0'); $opsm->title( "Operations Management Menu" ); my $opsmbtn1 = $opsmframe->Button( -text, 'List Creator', -command = +> sub { &listcreator; $opsm->iconify;})->grid( -row, 0, -column, +0, -sticky => 'nsew'); $balloon->attach($opsmbtn1, -balloonmsg => "List Creator"); my $opsmbtn2 = $opsmframe->Button( -text, 'Waybill Generator', -comm +and => sub { &waybillgenerator; $opsm->iconify;})->grid( -row, 1, +-column, 0, -sticky => 'nsew'); $balloon->attach($opsmbtn2, -balloonmsg => "Waybill Generator"); my $opsmbtn3 = $opsmframe->Button( -text, 'Material Order Creator', +-command => sub { &materialordercreator; $opsm->iconify;})->grid( -r +ow, 2, -column, 0, -sticky => 'nsew'); $balloon->attach($opsmbtn3, -balloonmsg => "Material Order Creator"); my $opsmbtn4 = $opsmframe->Button( -text, 'Truck Scheduler', -comman +d => sub { &truckscheduler; $opsm->iconify;})->grid( -row, 3, -column +, 0, -sticky => 'nsew'); $balloon->attach($opsmbtn4, -balloonmsg => "Truck Scheduler"); my $opsmbtn5 = $opsmframe2->Button( -text, 'Trailer Manifest', -comm +and => sub { &manifest; $opsm->iconify;})->grid( -row, 0, -column, 3, + -sticky => 'nsew'); $balloon->attach($opsmbtn5, -balloonmsg => "Trailer Manifest"); my $opsmbtn6 = $opsmframe2->Button( -text, 'Routes', -command => sub +{ &routes; $opsm->iconify;})->grid( -row, 1, -column, 3, -sticky => ' +nsew'); $balloon->attach($opsmbtn6, -balloonmsg => "Routes"); my $opsmbtn7 = $opsmframe2->Button( -text, 'Truck Hostler')->grid( -r +ow, 2, -column, 3, -sticky => 'nsew'); $balloon->attach($opsmbtn7, -balloonmsg => "Truck Hostler"); my $opsmbtn8 = $opsmframe2->Button( -text, 'Return To Main Menu', -co +mmand => sub { $opsm->withdraw; $mw->deiconify; $btn7->configure(-state=>'normal'), $btn10->configure(-state=>'normal' +) ;})->grid( -row, 3, -column, 3, -sticky => 'nsew'); $balloon->attach($opsmbtn8, -balloonmsg => "Return To Main Menu"); } else { $opsm->deiconify(); $opsm->raise(); } } # END OPERATIONS

Replies are listed 'Best First'.
Re^5: TK Submenus
by hdb (Monsignor) on Oct 28, 2013 at 18:00 UTC

    You still have not shown where you declare $opsm. It would be useful to see how that line looks like: my $opsm; or similar. Also in which order do you declare and call the functions you have provided so far.

    In addition I have two question to this snippet:

    if ( !Exists( $mm ) ) { my $mm = $mw->Toplevel(); ...

    Is Exists a Tk specific function (because of the capital E)? You declare a new variable $mm just after testing it in the line before. Is this intentional?

    Apologies for asking one question after the other but I still have no clear picture what is going on...

      $opsm, $mm and others are defined at the beginning of the program like this: my ($opsm, $mm, $sbm); I've since removed the If !Exists line and it still has no bearing...scratching my head here as the code is exactly like the previous menus. What should happen is once a Manifest has been added that window disappears which it does and the Manifest menu should reappear which it does not. If I try to call the Ops menu $opsm that works the $mm (Manifest Menu) does not iconify.