#!/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=> "About", -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 => 'left'); $entry_resetp->bind("", \$passwordreset_handle_return ); my $button = $mainwindow->Button(-text=>"Click to reset", -command => \$passwordreset_handle_return , -width => 15) -> pack ( -side=>'bottom' ); $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 => 40) -> pack ( -side=>'left'); my $entry_adduser = $mainwindow->Entry(-width => 30)->pack(-side => 'left'); $entry_adduser->bind("", \$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 ", -width => 40) -> pack ( -side=>'left'); my $entry_deleteuser = $mainwindow->Entry(-width => 30)->pack(-side => 'left'); $entry_deleteuser ->bind("", \$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"); } }