Tk::MenuDialog - A Moo based object oriented interface for creating and display a dialog of buttons to be used as a menu using Tk
Version 0.05
use Tk::MenuDialog; use File::Basename qw(dirname); my $menu = Tk::MenuDialog->new; ## Add the script's directory to the icon path ## when searching for icon files $menu->add_icon_path(dirname(__FILE__)); ## Add menu items to the menu $menu->add_item( label => qq{&Configure}, icon => qq{settings.png}, ); $menu->add_item( label => qq{&Run Tests}, icon => qq{run.png}, ); ## Allow operator to cancel the menu $menu->can_cancel(1); ## Display the menu and return hash reference of the selected item, ## or UNDEF if canceled my $selection = $menu->show;
Title of the menu
DEFAULT: ''
Indicates if the operator can close the dialog without a selection
DEFAULT: 1
Boolean value indicating if pressing the Escape key should simulate closing the window and canceling the dialog.
Array reference of items contained in this menu.
An array containing various paths to use when locating icon image files.
Font to use for the buttons.
DEFAULT: 'times 10'
Number of pixels between each button
DEFAULT: 0
Minimum width of the dialog.
DEFAULT: 300
Minimum height of the dialog.
DEFAULT: 80
Add a field to the form.
A hash reference with the following key / value pairs: label - Required paramater with icon - Optional filename of the icon to display icon_location - Optional location relative to button text for the icon DEFAULT: "left"
UNDEF on error, or the hash reference of the item created
Show the dialog as a new MainWindow.
The function will return if the users cancels the dialog or clicks a button
NONE
UNDEF when canceled, or the hash reference associated with the button clicked.
Description goes here
initialize the form from a HASH reference, JSON string, or JSON file. In all cases, the hash should have the following format
{ title => 'My Menu', can_cancel => 0, items => [ { label => '&Configure', icon => 'settings.png', }, { label => '&Run', icon => 'run.png', }, { label => 'E&xit', icon => 'exit.png', }, ] }
$param - HASH reference, or scalar containin JSON string, or filename
Paul Durden <alabamapaul AT gmail.com>
Copyright (C) 2015 by Paul Durden.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Tk::MenuDialog, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tk::MenuDialog
CPAN shell
perl -MCPAN -e shell install Tk::MenuDialog
For more information on module installation, please visit the detailed CPAN module installation guide.