Tk::TM::wApp - Tk Transaction Manager Application Window. See Tk::TM::Lib for main descriptions and principles.
use Tk::TM::wApp; use DBI; my $mw =new Tk::TM::wApp; $mw->setscr(0,'Login'); $mw->setscr(0,'Screen 1', \&Screen1); $mw->setscr(1,'Screen 1.1', \&Screen1_1); $mw->setscr(0,'Screen 2', \&Screen2); $mw->Start(); Tk::MainLoop; .............................. sub Screen1_1 { # two subs - for screen and for data object my ($self, $cmd, $opt, $mst) =@_; return(1) if $cmd =~/stop/; my $wgt=$self->{-wgscr}->tmTable( -rowcount=>10 ,-colspecs=>[['Col1' ,'Entry'] ,['Col2' ,'Entry'] ,['Col3' ,'Entry'] ,['Col4' ,'Entry']] )->pack; my $do; if (!$self->{-dos}) { $do =new Tk::TM::DataObject(); $self->{-dos} =[$do]; } else { $do =$self->{-dos}->[0]; } my $rwm =$mst->{-dos}->[0]->dsRowDta(); my $flt =$rwm->[0]; $self->{-title} =$flt; $do->set(-wgtbl=>$wgt ,-mdedt=>0 ,-cbdbRead=> sub{$_[0]->DBICmd("select * from table where field=?",$flt)} ); $do->Retrieve('#reread') } .............................. sub Screen1_2 { # unified sub for screen with single data object my ($self, $cmd, $opt, $row, $fld, $wg, $dta, $new) =(shift, shift, @_); if ($cmd eq 'stop') { return(1) } elsif ($cmd eq 'start') { my $wgt=$self->{-wgscr}->tmTable( -rowcount=>10 ,-colspecs=>[['Name','Entry']] )->pack; my $do; if (!$self->{-dos}) { $do =new Tk::TM::DataObject(); $self->{-dos} =[$do]; } else { $do =$self->{-dos}->[0]; } my $rwm =$row->{-dos}->[0]->dsRowDta(); $do->{-parm}->{XXX} =$rwm->[0]; $self->{-title} =$do->{-parm}->{dsn}; $do->set(-wgtbl=>$wgt ,-mdedt=>0 ,-cbcmd=>\&DataSources ); $do->Retrieve('#reread') } elsif ($cmd eq 'dbRead') { $self->DBICmd("select...", $self->{-parm}->{XXX}) } else {return $self->doDefault($cmd, @_)} } ..............................
This module implements application window with Tk Transaction Manager features. Tk::TM::wApp is level above Tk::TM::Lib, see there other descriptions and principles. There is no need to call 'use' for Tk::TM::Lib, this is done by using Tk::TM::wApp.
Tk::TM::wApp
Tk::TM::Lib
The components of application window are:
Data editing bar menu with toolbar, implemented with Tk::TM::wgMenu (tmMenu widget).
Tk::TM::wgMenu
tmMenu
Navigation pane with list of screen names to open, implemented with Tk::Tree.
Tk::Tree
Screen pane for widgets of application screens, implemented with Tk::Frame.
Tk::Frame
Tk parameters of Tk::TM::wApp window may be set via configure Tk method. They may be all parameters of Tk::MainWindow.
configure
Tk
Tk::MainWindow
TM parameters may be accessed via set method of Tk::TM. They are: -wgmnu, -wgnav, -wgscr, -title, -mdnav, -parm
set
Tk::TM
-wgmnu
-wgnav
-wgscr
-title
-mdnav
-parm
-mdnav = 'treee' || 'tree' || 'lst'
Mode of navigation between application screens. Default is 'treee' ('tree exact'), that means that detail screen may be opened only if it`s master screen is current; this mode may be excluded in future. Mode 'tree' means that detail screen should be opened for it`s master screen and if master was previously used. Mode 'lst' means that screens are using -parm values filled in 'stop' command of screen`s sub or doEnd event of data object.
doEnd
-parm = {}
Programmer`s parameters. This hash is also accessible via parameter -parm of tmMenu widget (Tk::TM::wgMenu), accessible via -wgmnu.
-title = $mw->cget(-title)
Title of application, the first part of window`s title. Other parts are combined for current application`s screen. Default value is title of the window.
Widget with list of all available application screens. This is navigation pane of application. Tk::Tree is used.
Menu and toolbar for data editing. tmMenu widget (Tk::TM::wgMenu) is used.
Widget for application screens, to create application widgets inside it. Tk::Frame widget is used.
Common object methods as new, initialize, set are described under Tk::TM::Lib.
new
initialize
Special methods are setscr, Start.
setscr
Start
setscr (level, label, ?sub, ?parm, ?opt)
Defines screen of application. Level is number of nest of screen in tree, where 0 is top level. Label of the screen will be displayed at the navigation pane and as part of the title of the window. Special label 'Login' is used for predefined login screen. Sub is code to create widgets and data objects of screen. Sub may also be filename relative to $0 path, it will be executed with do to obtain code. Parm is hash reference with parameters of the screen to use inside sub. Opt is hash reference with screen options, available via screen description, see \&callback.
do
\&callback
Opens the first screen of application.
setscr method defines callback to start and stop application screen. Parameters are description of this screen, command ('start' or 'stop'), option string, description of parent screen.
The command is string 'start' or 'stop'.
The descriptions are hash references with entries -cbcmd, -cbnme, -do, -dos, -wgapp, -wgmnu, -wgscr, -label, -title, -parm, -parmc, -reread, -rereadc
-cbcmd
-cbnme
-do
-dos
-wgapp
-label
-parmc
-reread
-rereadc
Start performance of screen. If -dos is not defined, this is the first open of screen.
Stop performance of screen. The operation may be declared with 'return(1)' only.
Reference to this callback sub.
Name of this callback sub for dynamic loading.
Reference to first data object in -dos list, to shorten access from outside.
Reference to list of data objects of screen. Callback should set it. At the first open of the screen this is not defined.
Label of the screen as displayed in -wgnav. Title of application window is combined with title of application, label of the screen, title of the screen (described below at -title)
Programmer`s parameters of the screen, defined with setscr hash ref. It is not the same as '-parm' in Tk::TM::wApp or Tk::TM::wgMenu.
Common to Tk::TM::wApp or Tk::TM::wgMenu object programmer`s parameters. This is also available via -wgapp or -wgmnu.
Reread this master screen internally before it's detail open.
Reread this master screen internally before it's detail open and turn off this toggle.
Title of the screen, represents data displayed on screen. Title of application window is combined with title of application, label of the screen (described above at -label), title of the screen.
Application window, provided by Tk::TM::wApp.
Application`s menu bar, provided by Tk::TM::wApp.
Widget for application screen, to create application widgets inside it. Provided by Tk::TM::wApp. Tk::Frame widget is used.
Status Line implemented.
exit calls replaced with Tk::exit calls to avoid abnormal program terminations.
exit
Tk::exit
Tk::TM::Common::DBILogin used for login screen.
Tk::TM::Common::DBILogin
setscr - Sub may be filename relative to $0 path, it will be executed with do to obtain code. Opt parameter added.
Master's DataObject data is not retrieved when it's detail opening, as in 'tree' mode was. Application supposes now that only current row of master data is needed and this is unchanged in database by other screens. To do internal reread -reread and -rereadc screen descriptions may be used.
Error processing for callbacks added.
-do screen description created.
-opt screen description removed, -parm should be used instead.
-opt
-parmc screen description created.
-wglst parameter of Tk::TM::wApp renamed to -wgnav.
-wglst
-mdlst parameter of Tk::TM::wApp renamed to -mdnav. New value 'treee' ('tree exact') is set as default.
-mdlst
TO DO:
- Approve
- Debug and Test
Created.
Andrew V Makarow <makarow@mail.com>, Denis E Medvedyuk <demed@mail.com>
2 POD Errors
The following errors were encountered while parsing the POD:
You can't have =items (as at line 149) unless the first thing after the =over is an =item
You can't have =items (as at line 209) unless the first thing after the =over is an =item
To install Tk::TM::Try, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tk::TM::Try
CPAN shell
perl -MCPAN -e shell install Tk::TM::Try
For more information on module installation, please visit the detailed CPAN module installation guide.