Dear Perl team,

I’m creating this below script that use tk gui Menu to Add, Delete, and Reset users in my environment now I’m doing the form design but could not get it to work like I want to I have tried the forget, destroy however it does not work or maybe I’m doing it wrong.

My Goal is when I click “Add” menu I can do add user in my form and when I click “Delete” menu I want the Add form to be clear and the Delete form will load the same as when I click the “Reset” menu it should clear the Delete form and load cleanly the next form. Can you please show me the way on how to do this. Thank you

#!/usr/local/bin/perl use strict; use warnings; use Tk; use feature 'say'; my $mainwindow = MainWindow->new(); $mainwindow->geometry("600x150"); $mainwindow->title("Add/Delete/Reset Password"); # Disable the window Resize $mainwindow->resizable(0,0); my $main_menu = $mainwindow->Menu(); $mainwindow->configure(-menu => $main_menu); # File my $menu_menu = $main_menu->cascade(-label=>"Menu", -underline => 0, - +tearoff=>0); $menu_menu->command(-label=>"Password Reset for users", -underline= +>0, -command=>\&Show_ResetPassword_menu); $menu_menu->command(-label=>"Add User", -underline=>0, -command=>\& +Show_AddUser_menu); $menu_menu->command(-label=>"Delete User", -underline=>0, -command= +>\&Show_DeleteUser_menu); # About $main_menu->command(-label=>"About", -underline => 0, -command=>sub{$mainwindow->messageBox(-title=> "Ab +out", -message=>"Version 3.0.0", -type => "ok")}); MainLoop(); sub Show_ResetPassword_menu { my $passwordreset_handle_return; my $label_resetp = $mainwindow->Label(-text=>"Password Reset for user +", -width => 40) -> pack ( -side=>'left'); my $entry_resetp = $mainwindow->Entry(-width => 30)->pack(-side => 'le +ft'); $entry_resetp->bind("<Return>", \$passwordreset_handle_return ); my $button = $mainwindow->Button(-text=>"Click to reset", -command => +\$passwordreset_handle_return , -width => 15) -> pack ( -side=>'botto +m' ); $passwordreset_handle_return = sub { say $mainwindow -> messageBox( -message=>"Password Reset", -title=> "Password", -type=>"ok", -icon=>"info"); } } sub Show_AddUser_menu{ my $adduser_handle_return; my $label_adduser = $mainwindow->Label(-text=>"Add user ", -width => 4 +0) -> pack ( -side=>'left'); my $entry_adduser = $mainwindow->Entry(-width => 30)->pack(-side => 'l +eft'); $entry_adduser->bind("<Return>", \$adduser_handle_return); my $button = $mainwindow->Button(-text=>"Click to reset", -command => +\$adduser_handle_return, -width => 15) -> pack ( -side=>'bottom' ); $adduser_handle_return = sub { say $mainwindow -> messageBox( -message=>"Add User", -title=> "ADD", -type=>"ok", -icon=>"info"); } } sub Show_DeleteUser_menu { my $deleteuser_handle_return; my $label_deleteuser = $mainwindow->Label(-text=>"Delete User ", -widt +h => 40) -> pack ( -side=>'left'); my $entry_deleteuser = $mainwindow->Entry(-width => 30)->pack(-side => + 'left'); $entry_deleteuser ->bind("<Return>", \$deleteuser_handle_return); my $button = $mainwindow->Button(-text=>"Click to reset", -command => +\$deleteuser_handle_return, -width => 15) -> pack ( -side=>'bottom' ) +; $deleteuser_handle_return = sub { say $mainwindow -> messageBox( -message=>"Delete User", -title=> "DELETE", -type=>"ok", -icon=>"info"); } }

-when this script load and select the Add menu then click again the Reset menu it will load in the screen form


In reply to Resolved: tk widget - How to hide and unhide the forms in my script by fsmendoza

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.