Tk::Wizard::Installer - Building-blocks for a software install wizard
use Tk::Wizard::Installer; my $wizard = new Tk::Wizard::Installer( -title => "Installer Test", ); $wizard->addDownloadPage( -no_retry => 1, -files => { 'http://www.cpan.org/' => './cpan_index1.html', }, ); $wizard->addPage( sub { return $wizard->blank_frame( -title=>"Finished", -subtitle => "Please press Finish to leave the Wizard.", -text => "" ); }); $wizard->Show; MainLoop;
This module makes the first moves towards a Tk::Wizard extension to automate software installation, primarily for end-users, in the manner of InstallShield.
Tk::Wizard
If you are looking for a freeware software installer that is not dependent upon Perl, try Inno Setup - http://www.jrsoftware.org/. It's so good, even Microsoft have been caught using it.
http://www.jrsoftware.org/
Tk::Wizard::Installer supports all the methods and means of Tk::Wizard plus those listed in the remainder of this document.
Tk::Wizard::Installer
$wizard->addLicencePage ( -filepath => $path_to_licence_text )
Adds a page (a Tk::Frame) that contains a scroll text box of a licence text file specified in the -filepath argument. Presents the user with two options: accept, or don't accept. The user cannot progress until the former option has been chosen. The choice is entered into the object field licence_agree, which is automatically tested when the Next button is pressed, or with the Wizard's callback_licence_agreement function. You can over-ride this last action by providing your own -preNextButtonAction callback.
-filepath
licence_agree
callback_licence_agreement
-preNextButtonAction
$wizard->addFileListPage ( name1=>value1 ... nameN=>valueN )
Adds a page (a Tk::Frame) that contains a progress bar (Tk::ProgressBar) which is updated as a supplied list of files is copied or moved from one location to another.
The Next and Back buttons of the Wizard are disabled whilst the process takes place.
The two arguments (below) -to and -from should be references to arrays (or anonymous arrays), where entries in the former are moved or copied to the locations specified to the equivalent entries in the latter, renaming and path creation occurring as needed:
-to
-from
-copy => 1, -from => [ '/html/index.html', '/html/imgs/index.gif', '/html/oldname.html' ], -to => [ '/docs/', '/docs/imgs/', '/html/newname.html' ],
The above example copies index.html to /docs/index.html, index.gif is copied to become /docs/imgs/index.gif, and oldname.html is copied to newname.html in the same html directory.
index.html
/docs/index.html
index.gif
/docs/imgs/index.gif
oldname.html
newname.html
html
Arguments:
See "blank_frame" in Tk::Wizard.
Setting one or the other will determine whether files are copied (without deletion of originals) or moved (with deletion of originals). The default action is the former.
Reference to an array of locations to copy/move from
Reference to an array of locations to move/copy to
Delay (in mS) before copying begins (see Tk::after). Default is 1000.
Prevents display of the next Wizard page once the job is done.
A list of properties to pass to the Tk::ProgessBar object created and used in this routine. Assumes reasonable defaults.
Text for the label frame (Tk::LabFrame object) which contains our moving parts. Defaults to Copying Files.
Copying Files
Text for label displayed whilst counting files to be copied. Defaults to Preparing....
Preparing...
The text of the label prepended to the name of the directory being copied. Defaults to From:.
From:
The text of the label prepended to the name of the file being copied. Defaults to Copying:.
Copying:
A code reference to handle errors, which are detailed in the anonymous hash -failed, where names are filenames and values are the error messages. If not supplied, calls "pre_install_files_quit".
-failed
Path at which to store an uninstall database file for use with addUninstallPage. This path will be used to create two files, one with a dir extension and one with a pag extension.
dir
pag
If you supply -uninstall_db to create an uninstaller, you may use this argument to provide a file permissions for the db files; otherwise, the default is 0666. Please see the notes in SDBM_File that explain why 0666 is a good choice.
-uninstall_db
0666
SDBM_File
Alias for addFileListPage.
$wizard->addDownloadPage( name1 => value1 ... nameN => valueN )
Adds a page that will attempt to download specified files to specified locations, updating two progress bars in the process.
If a file cannot be downloaded, the user will be prompted to try again. If the user sooner or later wishes to carry on even though a file has not downloaded, the calling Wizard's -failed slot is filled with the URIs of the files that could not be downloaded, and the supplied -on_error argument comes into play - see below. If no -on_error parameter is provided, the Wizard will continue.
Wizard
-on_error
The Next and Back buttons of the Wizard are disabled whilst the download process takes place.
A reference to a hash, where keys are URIs and values are local locations to place the contents of those URIs.
WARNING: Files that are successfully downloaded will be deleted from the hash.
If supplied, the frame will remain on the screen when the download is complete - default is to automate a click on the next button once the downloads are completed without errors.
next
If set to a true value, will prevent the Try again? dialogue.
If a file cannot be downloaded and the user chooses not to keep trying, then this parameter comes into operation. If it is a reference, then it is assumed to be a code reference to execute; otherwise a dialogue box asks the user if they really wish to quit. If they do, then the Tk::Wizard CloseWindow event cycle is triggered -- the default result of which is probably yet another confirmation of closure....
If no -on_error parameter is provided, the Wizard will continue even if it cannot download the requested data.
Text to display when complete. Default: complete.
Would it be useful to implement globbing for FTP URIs?
Intended to be used with an action-event handler like -preNextButtonAction, this routine check that the object field licence_agree is a Boolean true value. If that operand is not set, it warns the user to read the licence; if that operand is set to a Boolean false value, a message box says goodbye and quits the program.
This callback is triggered when a file download fails during a DownloadPage. In the default implementation, the user is asked if they would like to try again (Yes or No).
This callback is triggered when the -on_error condition happens at the end of a DownloadPage. In the default implementation, the user is asked if they would like to abort the entire installation process (Yes or No).
Asks if the user wishes to continue after file copy errors.
Basically the same as addFileListPage, but rather than taking arguments to indicate from and to where files are to be moved or copied, takes the argument -uninstall_db, which should be the same value as supplied to addFileListPage.
Called when the user tries to quit. As opposed to the base Wizard's dialogue of the same name, this dialogue refers to "the Installer", rather than "the Wizard".
The labels of the licence can be changed (perhaps into a language other an English) by changing the values of the package-global %LABELS hash, at the top of the source. This will be revised in a future version.
%LABELS
Please see other functions' arguments for label-changing parameters.
It would be nice to have an 'Estimated Time Remaining' feature for the copy routines.
How about a remove-before-copy feature, and removing of directories? When there is time, yes.
Tk::LabFrame; File::Path; Tk::ProgressBar; File::Spec; File::Copy; Tk; Tk::Wizard; Tk::Wizard::Install::Win32.
Lee Goddard (lgoddard @ cpan.org).
Wizard; set-up; setup; installer; uninstaller; install; uninstall; Tk; GUI.
Lee Goddard (lgoddard@cpan.org).
Copyright (C) Lee Goddard, 11/2002 - 01/s ff.
Made available under the same terms as Perl itself.
To install Tk::Wizard, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tk::Wizard
CPAN shell
perl -MCPAN -e shell install Tk::Wizard
For more information on module installation, please visit the detailed CPAN module installation guide.