in reply to Resolved: tk widget - How to hide and unhide the forms in my script
#!/usr/local/bin/perl use strict; use warnings; use Tk; my $mainwindow = MainWindow->new(); $mainwindow->geometry("600x150"); $mainwindow->title("Add/Delete/Reset Password"); # Disable the window Resize # $mainwindow->resizable(0,0); # Why??? don't need it? 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", -command=>sub{$mainwindow->messageBox(-title=> "Ab +out", -message=>"Version 3.0.0", -type => "ok")}); MainLoop(); my $user; sub password_reset { my $answer = $mainwindow -> messageBox( -message=>"Password Reset for user: $user", -title=> "Password", -type=>"YesNoCancel", -icon=>"info"); if ($answer =~ /yes/i) { # code to reset password goes here.... # whatever log messasges you want print "PASSWORD RESET SUCEEDED: $user\n"; # a log entry? } else { print "PASSWORD RESET ABORTED: $user\n"; # a log entry? } } sub Show_ResetPassword_menu { my $label_resetp = $mainwindow->Label(-text=>"Password Reset for u +ser ", -width => 40) -> pack ( -side=>'left'); my $entry_resetp = $mainwindow->Entry(-width => 30, -textvariable +=>\$user )->pack(-side => 'left'); $entry_resetp->bind("<Return>", \&password_reset); my $button = $mainwindow->Button(-text=>"Click to reset", -command + => \&password_reset , -width => 15) -> pack ( -side=>'bottom' ); } # more code modifications to be done by poster.... sub add_user { my $answer = $mainwindow -> messageBox( -message=>"Add user: $user", -title=> "Password", -type=>"ok", -icon=>"info"); } sub Show_AddUser_menu { my $label_adduser = $mainwindow->Label(-text=>"Add user ", -width +=> 40) -> pack ( -side=>'left'); my $entry_adduser = $mainwindow->Entry(-width => 30)->pack(-side = +> 'left'); # $entry_adduser->bind("<Return>", \$adduser_handle_return); my $button = $mainwindow->Button(-text=>"Click to reset", -command + => \&adduser, -width => 15) -> pack ( -side=>'bottom' ); } 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 { $mainwindow -> messageBox( -message=>"Delete User", -title=> "DELETE", -type=>"ok", -icon=>"info"); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: tk widget - How to hide and unhide the forms in my script
by fsmendoza (Novice) on Mar 02, 2017 at 09:42 UTC | |
by Marshall (Canon) on Mar 02, 2017 at 22:46 UTC | |
by fsmendoza (Novice) on Mar 10, 2017 at 09:22 UTC | |
by Marshall (Canon) on Mar 10, 2017 at 21:19 UTC | |
by fsmendoza (Novice) on Mar 11, 2017 at 04:22 UTC | |
by Discipulus (Canon) on Mar 02, 2017 at 12:47 UTC |