Tk::Help - Simple widget for creating a help system for Perl/Tk applications
use Tk::Help; my $help = $main->Help(-variable => \@array);
This is an answer to a personal need to be able to create help systems for my Perl/Tk applications. Originally, I just created a really big dialog and formatted all the text, which was tedious and clumsy. I wanted to create something that looked 'similar' to the Windows help. This is by no means as featured or fluid as the Windows help, but it should provide a (somewhat) simple means to create a help dialog where all someone should need to do is create the array with their help content.
Set the font family for all text in the Help widget.
Sets the background color of the details section (right side) of the help window. Default is white.
white
Sets the borderwidth around the inside of the details section (right side) of the help window. Default is 10.
10
Sets the font size of the details text. This is separate from the header text that appears in each detail window. Default is 8.
8
Sets the color of the details text. This is separate from the header color that appears in each detail window. Default is the OS's default text color for Windows and black otherwise.
black
Sets the font size of the headers in the details window above the text. This is separate from the details text. Default is 9.
9
Sets the color of the headers in the details window above the text. This is separate from the details text. Default is the OS's default text color for Windows and black otherwise.
Determines if the right-click menu is active for the details section. Takes a boolean value. Default is 0.
0
Sets the width of the details section. Default is 40.
40
Sets the height for the help window. Default is 30 for Windows and 40 otherwise.
30
Sets the icon on the title bar of the application. This must be passed as a reference. Default is the red 'Tk' icon for Windows and the system default otherwise.
Sets the background color of the list section (left side) of the help window. Default is the OS's default application color, (Tk::NORMAL_BG).
(Tk::NORMAL_BG)
Sets the borderwidth around the inside of the list section (left side) of the help window. Default is 0.
Sets the mouse cursor that is used over items in the list section (left side). Default is Perl/Tk's hand2 cursor. To use the OS's default cursor, set -listcursor => 'default'.
hand2
-listcursor => 'default'
Sets the font size of the list text. Default is 8.
Sets the color of the list text. Default is the OS's default text color for Windows and black otherwise.
Sets the background color of the selected list item. Default is whatever -listbackground is set to.
-listbackground
Sets the color of the selected list item's text. Default is blue.
blue
Sets the type of listbox Help is to use, either HList or Tree. Default is HList.
HList
Sets the width of the list section of the help window. Default is 25.
25
Determines if the help window is resizable or not. Takes a boolean value. The default is set to 0.
Sets the title on the top of the window. Default is 'Help'.
'Help'
The structure should be an array of arrayrefs of hashrefs. The very first arrayref should contain only one hashref and this will be the root of your entire help tree. This must be passed as a reference. This is required and there is no default.
use Tk; use Tk::Help; my $main = MainWindow->new(-title => "My Application"); $main->configure(-menu => my $menubar = $main->Menu); my $filemenu = $menubar->cascade(-label => "~File", -tearoff => 0); my $helpmenu = $menubar->cascade(-label => "~Help", -tearoff => 0); $filemenu->command(-label => "E~xit", -command => sub{$main->destroy}); $helpmenu->command(-label => "~Help Contents", -command => sub{showhelp()}); MainLoop; 1; sub showhelp { my @helparray = ([{-title => "My Application", -header => "My Application Help", -text => "This is a description of my application for the help."}], [{-title => "Section 1", -header => "\n\nSection 1 Help", -text => ""}, {-title => "1st Feature", -header => "The 1st Feature", -text => "This is the text describing the 1st feature of section 1."}, {-title => "2nd Feature", -header => "The 2nd Feature", -text => "This is the text describing the 2nd feature of section 1."}], [{-title => "Section 2", -header => "\n\nSection 2 Help", -text => ""}, {-title => "1st Feature", -header => "The 1st Feature", -text => "This is the text describing the 1st feature of section 2."}, {-title => "2nd Feature", -header => "The 2nd Feature", -text => "This is the text describing the 2nd feature of section 2."}]); my $helpicon = $main->Photo(-file => "/path/to/some/gif/or/bmp"); my $help = $main->Help(-icon => \$helpicon, -title => "My Application - Help", -variable => \@helparray); }
- Bind mouse events to the list items to create a mouseover and mouseout effect. - Figure out how to remove the dashed line around a selected item in the list. - Add individual font family switches for each text group.
Tk::Toplevel, Tk::HList, Tk::Tree
help
Doug Gruber <dougthug@cpan.org> http://www.dougthug.com/
Copyright (c) 2005 Doug Gruber. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Tk::Help, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tk::Help
CPAN shell
perl -MCPAN -e shell install Tk::Help
For more information on module installation, please visit the detailed CPAN module installation guide.