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

hai everybody i have a menu with menuitems like history,habitat etc. now my problem is after clicking the menu item i created a textbox now the particular menuitem should be disabled can anybody suggest a way


use Tk; $main=MainWindow->new; $menubar=$main->Frame->pack(-side=>'top',-fill=>'x'); $ragimenu= $menubar->Menubutton(-text=>'Ragi')->pack(-side=>'left'); $ragimenu->command(-label=>'History',-command=>\&history); sub history { $test=$main->Entry->pack(); $ragimenu->configure(-state=>disabled); } MainLoop;

Replies are listed 'Best First'.
Re: how to disable a menuitem at runtime
by jbrugger (Parson) on Jul 21, 2005 at 08:48 UTC
    > hai everybody i have created a menubar with menubuttons now i must diasable the menubutton after creating a textbox in the window in runtime please suggest me a way

    please read Re: How (Not) To Ask A Question.
    It's totally not clear what you exactly need.

    e.g. Is it about generated html / javascript? tcl? gtk? etc. etc.

    "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.
Re: how to disable a menuitem at runtime
by zentara (Cardinal) on Jul 21, 2005 at 11:51 UTC
    It's not very obvious why, but.....
    sub history { $test = $main->Entry->pack(); # $ragimenu->Menubutton( -state => 'disabled' ); $ragimenu->entryconfigure(1, -state => 'disabled'); }

    I'm not really a human, but I play one on earth. flash japh
Re: how to disable a menuitem at runtime
by anonymized user 468275 (Curate) on Jul 21, 2005 at 08:51 UTC
    Well I suppose we could guess this is a Tk question, although for all we know it could be any GUI, html etc, or even block character pseudo-graphics on an IBM terminal... !

    Best is to publish your code here anyway; we'll see what it is and hopefully the solution.

    One world, one people

Re: how to disable a menuitem at runtime
by anonymized user 468275 (Curate) on Jul 21, 2005 at 09:55 UTC
    $ragimenu->Menubutton(-state=>'disabled');

    One world, one people

      use Tk;
      $main=MainWindow->new;
      $menubar=$main->Frame->pack(-side=>'top',-fill=>'x');
      $ragimenu= $menubar->Menubutton(-text=>'Ragi')->pack(-side=>'left');
      $ragimenu->command(-label=>'History',-command=>\&history);
      $searchbar=$menubar->Menubutton(-text=>'Search')->pack(-side=>'left');
      $searchbar->command(-label=>'Literature search',-command=>\&literature);
      $searchbar->command(-label=>'Genome search',-command=>\&genome);
      sub history
      {
      $test=$main->Entry->pack();
      $ragimenu->Menubutton(-state=>'disabled');
      }
      MainLoop;
      i have tried by placing the $ragimenu->Menubutton(-state=>'disabled');
      but that to does't works it still active
        Unfortunately I can't install Tk.pm in the office, so I am flying blind here. But the next thing I would try is moving that line into the main loop, instead of in the history subroutine.

        One world, one people