objscanner(3)
NAME
Tk::ObjScanner - Tk data scanner
SYNOPSIS
use Tk::ObjScanner;
my $scanner = $mw->ObjScanner( caller => $object,
title=>"windows") -> pack
;
my $mw -> ObjScanner
(
caller => $object,
title => 'demo setting the scanner
options',
background => 'white',
selectbackground => 'beige',
foldImage => $mw->Photo(-file => Tk->findINC('folder.xpm')),
openImage => $mw->Photo(-file => Tk->findINC('openfolder.xpm')),
itemImage => $mw->Photo(-file => Tk->findINC('textfile.xpm')),
)
-> pack(expand => 1, fill => 'both') ;
DESCRIPTION
The scanner provides a GUI to scan the attributes of an
object. It can also be used to scan the elements of a hash
or an array.
The scanner is a composite widget made of a Tk::HList and
a text window (actually a TK::ROText). This widget acts as
a scanner to the object (or hash ref) passed with the
'caller' parameter. The scanner will retrieve all keys of
the hash/object and insert them in the HList.
When the user double clicks on a key, the corresponding
value will be added in the HList.
If the value is a scalar, the scalar will be displayed in
the text window. (Which is handy if the value is a multiline string)
Constructor parameters
- · caller: The ref of the object or hash or array to scan
- (mandatory).
- · title: the title of the menu created by the scanner
- (optional)
- · destroyable: If set, a menu entry will allow the user
- to destroy the scanner widget. (optional, default 1) .
You may want to set this parameter to 0 if the destroy
can be managed by a higher level object. - · background: the background color for subwidgets
- (optional)
- · selectbackground: the select background color for
- HList (optional)
- · itemImage: the image for a scalar item (optional,
- default 'file.xbm')
- · foldImage: the image for a composite item (array or
- hash) when closed (optional, default 'folder.xbm')
- · openImage: the image for a composite item (array or
- hash) when open (optional, default 'openfolder.xbm')
WIDGET-SPECIFIC METHODS
updateListBox
Update the keys of the listbox. This method may be handy
if the scanned object wants to update the listbox of the
scanner when the scanned object gets new attributes.
CAVEATS
The name of the widget is misleading as any data (not only
object) may be scanned. This widget is in fact a DataScan
ner.
ObjScanner may fail if an object involves a lot of inter
nal perl magic. In this case, I'd be glad to hear about
and I'll try to fix the problem.
ObjScanner does not detect recursive data structures. It
will just keep on displaying the tree until the user gets
tired of clicking on the HList items.
There's no sure way to detect if a reference is a pseudohash or not. When a reference is believed to be a
pseudo-hash, ObjScanner will display the content of the
reference like a hash. If the reference is should not be
displayed like a pseudo-hash, you can turn off the pseudohash view with the check button on the top right of the
widget.
THANKS
To Rudi Farkas for all the improvements provided to ObjS
canner.
To Slaven Rezic for the propotype code of the pseudo-hash
viewer.
AUTHOR
Dominique Dumont, Dominique_Dumont@grenoble.hp.com
Copyright (c) 1997-2001 Dominique Dumont. All rights
reserved. This program is free software; you can redis
tribute it and/or modify it under the same terms as Perl
itself.