|
NAMETk::Role::Dialog - moose role for enhanced tk dialogsVERSIONversion 1.112380SYNOPSISpackage Your::Tk::Dialog::Class; use Moose; with 'Tk::Role::Dialog'; sub _build_title { 'window title' } sub _build_icon { '/path/to/some/icon.png' } sub _build_header { 'big dialog header' } sub _build_resizable { 0 } sub _build_ok { 'frobnize' } # call $self->_valid sub _build_cancel { 'close' } # close the window sub _build_gui { my ($self, $frame) = @_; # build the inner dialog widgets in the $frame } sub _valid { # called when user clicked the 'ok' button $self->close; } # in your main program use Your::Tk::Dialog::Class; # create & show a new dialog Your::Tk::Dialog::Class->new( parent => $main_window ); DESCRIPTIONTk::Role::Dialog is meant to be used as a Moose role to be composed for easy Tk dialogs creation.It will create a new toplevel with a title, and possibly a header as well as some buttons. One can create the middle part of the dialog by providing a "_build_gui()" method, that will receive a Tk::Frame where widgets are supposed to be placed. The attributes (see below) can be either defined as defaults using the "_build_attr()" methods, or passed arguments to the constructor call. The only mandatory attribute is "parent", but you'd better provide some other attributes if you want your dialog to be somehow usable! :-) ATTRIBUTESparentThe parent window of the dialog, required.hiddenWhether the dialog should popup or stay hidden after creation. Default to false, which means the dialog is shown.iconThe path to an image to be used as window icon. Default to empty string (meaning no customized window icon), but not required.titleThe dialog title, default to "tk dialog".headerA header (string) to display at the top of the window. Default to empty string, meaning no header.imageThe path to an image to be displayed alongside the dialog text. Not taken into account if "text" attribute is empty. Default to empty string, meaning no image.textSome text to be displayed, for simple information dialog boxes. Default to empty string, meaning dialog is to be filled by providing a "_build_gui()" method. Can be combined with an "image" attribute for enhanced appearance.resizableA boolean to control whether the dialog can be resized or not (default).okA string to display as validation button label. Default to empty string, meaning no validation button. The validation action will call "$self->_valid()".cancelA string to display as cancellation button label. Default to empty string, meaning no cancellation button. The cancel action is to just close the dialog.hideA string to display as hiding button label. Default to empty string, meaning no hiding button. The hiding action is to just hide the dialog (think "withdraw").METHODSclose$dialog->close; Request to destroy the dialog. SEE ALSOYou can look for information on this module at:
AUTHORJerome QuelinCOPYRIGHT AND LICENSEThis software is copyright (c) 2010 by Jerome Quelin.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Visit the GSP FreeBSD Man Page Interface. |